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 ?
Programatically setting Site Collections Administrators in SharePoint 2010 using Client Object Model
2 Answers
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
-
This answer more precisely addresses the initial question, so +1 Oct 22, 2013 at 19:54
-
I have SP2013 with the v16 API. Whenever I change the IsSiteAdmin property it is not stored.– WoutJun 26, 2014 at 11:49
-
-
@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. Mar 16, 2015 at 17:53
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:
-
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. 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! 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 Oct 23, 2013 at 9:57
-
1
-
1Well, it's actually quite a different answer. You probably shouldn't have removed the initial response completely - now the comments are out of context. Oct 30, 2013 at 7:32