4

I am writing a program where I want to be able to add/remove user/groups as administrator for a given Site Collection. I am using Client Object Model API for SharePoint 2010. I havent been able to find any API which would allow me to do that. Is this something which is even possible via Client Object Model? If yes how ?

2 Answers 2

2

You can't do that with 2010 client object model but it is now possible with 2013.

For promoting a user to Site collection admin we need to:

  • Set the IsSiteAdmin property to true.

Having said that you can't set the IsSiteAdmin property via 2010 client object model.

However, it is quite possible to do it via:

  • Server side object model
  • PowerShell
4
  • This answer more precisely addresses the initial question, so +1 Commented Oct 22, 2013 at 19:54
  • I have SP2013 with the v16 API. Whenever I change the IsSiteAdmin property it is not stored. Commented Jun 26, 2014 at 11:49
  • Are you using JSOM or CSOM? Commented Jun 27, 2014 at 0:09
  • @FalakMahmood Is there a way to do this using REST API or any webservice? I need to add an admin as Site Collection Admin to some tenant users, but the problem is that this admin user is NOT a site user on any of these OneDrive (my site) and I have the access token for this ADMIN user with all permissions. Commented Mar 16, 2015 at 17:53
0

EDIT

just looked over the code and your right it doesnt work, I had a deep look at the webservices ootb provided by sharepoint and there is no function to perform the job!! so the next solution would be to make your own webservice that does it for you!

within the webservice add:

public bool SetSiteCollAdmin(string siteURL,string userAccount)
{ 
   using(SPSite site=new SPSite(siteURL)) 
   { 
      using (SPWeb web = site.RootWeb) 
      { 
          SPUser user = web.EnsureUser(userAccount); 
          user.IsSiteAdmin = true; 
          user.Update();
          return true;
      } 
   } 
   return false;
}

call that method with Ajax soap call.

to create a webservice follow:

http://msmvps.com/blogs/windsor/archive/2011/11/04/walkthrough-creating-a-custom-asp-net-asmx-web-service-in-sharepoint-2010.aspx

6
  • Although you add value, the answer is not strictly on topic and misleads. By adding users to groups you don't grant them IsSiteAdmin status. Commented Oct 22, 2013 at 19:53
  • im sorry @AlexeyKrasheninnikov but your missing the op question, "I want to be able to add/remove user/groups as administrator for a given Site Collection." This answer is on topic and is not misleading what so ever the code above removes the user from a selected group using that webservice, tweaking it can also remove user! Commented Oct 22, 2013 at 23:56
  • I agree with @AlexeyKrasheninnikov. What you have mentioned is adding a user to a group. I am not sure how this solves my problm of making a user site administrator Commented Oct 23, 2013 at 9:57
  • 1
    just ammended my solution! sorry for the run around ;) Commented Oct 23, 2013 at 10:34
  • 1
    Well, it's actually quite a different answer. You probably shouldn't have removed the initial response completely - now the comments are out of context. Commented Oct 30, 2013 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.