为什么我在 SharePoint Online CSOM 中执行 site.Owner 时得到的是站点管理员而不是站点所有者?
Why am I getting site Administrator instead of site owner while doing site.Owner in SharePoint Online CSOM?
我有这个代码,
using (var ctx = new ClientContext(Url))
{
//Validating the User credentials
ctx.Credentials = new SharePointOnlineCredentials(userName, securepass);
var site = ctx.Site;
ctx.Load(site, siteProperties);
var rootSite = site.RootWeb;
ctx.Load(rootSite, Properties);
ctx.ExecuteQuery();
Console.WriteLine($"Site Owner: {site.Owner.Email}");
这应该打印我 "anil@kaialsh.cf" 但它却打印 "Company Administrator",为什么?那么有没有其他方法可以得到网站所有者?请帮忙。
using (ClientContext ctx = new ClientContext("https://Tenant.sharepoint.com/"))
{
ctx.Credentials = new SharePointOnlineCredentials(account, secret);
ctx.Load(ctx.Web,a=>a.AssociatedOwnerGroup.Users);
ctx.ExecuteQuery();
if (ctx.Web.AssociatedOwnerGroup!=null)
{
foreach (var user in ctx.Web.AssociatedOwnerGroup.Users)
{
Console.WriteLine(user.Email);
}
}
}
我有这个代码,
using (var ctx = new ClientContext(Url))
{
//Validating the User credentials
ctx.Credentials = new SharePointOnlineCredentials(userName, securepass);
var site = ctx.Site;
ctx.Load(site, siteProperties);
var rootSite = site.RootWeb;
ctx.Load(rootSite, Properties);
ctx.ExecuteQuery();
Console.WriteLine($"Site Owner: {site.Owner.Email}");
这应该打印我 "anil@kaialsh.cf" 但它却打印 "Company Administrator",为什么?那么有没有其他方法可以得到网站所有者?请帮忙。
using (ClientContext ctx = new ClientContext("https://Tenant.sharepoint.com/"))
{
ctx.Credentials = new SharePointOnlineCredentials(account, secret);
ctx.Load(ctx.Web,a=>a.AssociatedOwnerGroup.Users);
ctx.ExecuteQuery();
if (ctx.Web.AssociatedOwnerGroup!=null)
{
foreach (var user in ctx.Web.AssociatedOwnerGroup.Users)
{
Console.WriteLine(user.Email);
}
}
}