jeudi 19 mars 2015

ClientContext sharepoint to get allowed site for user



I'd like to connect to a clientcontext `



using (SP.ClientContext ctx = new ClientContext("spurl"))
{
try
{
//retrieve an other user and use this
SP.User user = clientContext.Web.EnsureUser("me@myco.com");
ctx.Load(user);
ctx.ExecuteQuery();
}
catch (ServerException) { }

//load all webs in site collection
List<Web> allWebs = new List<Web>();
LoadAllWebs(ctx.Site.RootWeb, allWebs);
//print
foreach (SP.Web web in allWebs)
{
ctx.Load(web.CurrentUser);
ctx.ExecuteQuery();
string login = web.CurrentUser.LoginName;

dr = dt.NewRow();
dr["siteTitle"] = login;
dr["siteurl"] = web.Url;
dt.Rows.Add(dr);
}
}


My need is get allowed site for specific user but my script run with a people who is site collection administrator.


Are there a way to get allowed site for specific user? Are there a way to connect the clientcontext for a specific user?








0 commentaires:

Enregistrer un commentaire