0

How to add SiteCollection Administrator in SharePoint 2010 using CSOM(c#)? 'IsSiteAdmin' property is not available for SharePoint 2010.

Can I accomplish this by updating "isSiteAdmin" field value for the user in "SiteUserInfoList"? I tried below code, no exception is thrown and value remains unchanged

User user = web.EnsureUser(LoginName);
context.Load(user);
context.ExecuteQuery();
ListItem it = web.SiteUserInfoList.GetItemById(user.Id);
it["IsSiteAdmin"] = false;
it.Update();
context.ExecuteQuery();
0

Try this ,

 User spUser = null;

  var spContext = SharePointContextProvider.Current.GetSharePointContext  (HttpContext);

  using (var clientContext = spContext.CreateUserClientContextForSPHost()) 
 { 
   if (clientContext != null) 
   { 
    spUser = clientContext.Web.EnsureUser("username@domain.com or DOMAIN\LoginName"); 
    spUser.IsSiteAdmin = true; 
    spUser.Update();

    clientContext.Load(spUser); 
    clientContext.ExecuteQuery(); 

    ViewBag.UserName = spUser.Title; 
} 
}
  • User.IsSiteAdmin property is not available for SharePoint 2010. is there any other way to do this? – Mani Dharmarajan Feb 22 '16 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.