我需要检索用户可以使用客户端对象模型访问的子站点。
这是我所拥有的:
NetworkCredential credential = new NetworkCredential(user, pwd, domain);
ClientContext clientContext = new ClientContext(string.Format("http://{0}:{1}/", server, port));
clientContext.Credentials = credential;
Web oWebsite = clientContext.Web;
clientContext.Load(oWebsite, website => website.Webs, website => website.Title);
clientContext.ExecuteQuery();
infos = new List<Infos>();
Infos info = null;
for (int i = 0; i != oWebsite.Webs.Count; i++)
{
info = new Infos();
info.SubSite = oWebsite.Webs[i].Title;
info.UrlSubSite = oWebsite.Webs[i].ServerRelativeUrl;
ListCollection lists = oWebsite.Webs[i].Lists;
clientContext.Load(lists);
clientContext.ExecuteQuery();
foreach (var list in lists)
{
Lists myList = new Lists();
myList.Title = list.Title;
info.Listas.Add(myList);
}
infos.Add(info);
}
var query = from Infos i in infos
select i.SubSite;
return query.ToList();
}
catch(Exception ex)
{
throw ex;
}
return null;
}
=====
使用此代码,我收到403 禁止错误。我的客户端用户无权访问根站点(我在 ClientContext 构造函数中使用)。但他有一些子网站。我需要使用客户端对象模型获取他有权访问的子站点(只需将它们全部列出)。
还有其他方法吗?