Monday, January 7, 2013

Change Site Collection Primary, Secondary Administrators in SharePoint

Site collection administrators have god like power within a site collection, They can add/delete sites, content, users, etc for any site within a site collection.

Change site collection administrator in SharePoint 2010: In SharePoint 2010 primary, secondary site collection administrators are set from Central Administration >> Application Management >> Change site collection administrators under Site Collection.

sharepoint 2010 change primary, secondary site collection administrator

How to change site collection administrator in SharePoint 2007 / SharePoint 2010 using STSADM:
To change primary site owner, secondary site owner in MOSS 2007, we use stsadm with siteowner switch.
stsadm -o siteowner -url -ownerlogin domain\user -secondarylogin global\salaudeen"

You can find site collection Primary and Secondary administrators under site collection administrators group (Site Actions >> Site Settings >> Site collection administrators) along with other site collection administrators. But Primary and Secondary Administrators are the only users who receive e-mail notifications for events, such as the quota reached, Site usage confirmation, etc.

Set site collection administrator in SharePoint programmatically:
To change primary administrator in SharePoint site with object model code C#:
String PrimaryOwner="Global\Salaudeen";
SPSite oSpSite = new SPSite(URL);
SPWeb oSPWeb = oSpSite.OpenWeb();
oSpSite.Owner = oSPWeb.EnsureUser(PrimaryOwner);
//oSpSite.SecondaryContact = oSPWeb.EnsureUser(SecondaryOwner);
This code sets SharePoint primary site collection administrator

Change site collection administrator in SharePoint 2010 using PowerShell:
In SharePoint 2010 onwards PowerShell cmdlets makes it much simpler:
To get Primary and Secondary Site collection Administrators:
Get-SPSite -Limit all | Select URL, Owner, SecondaryContact | Out-Gridview

Similarly, to set Site collection Primary and secondary owners, we can use the powershell cmdlet: Set-SPSite
Set-SpSite "" -owneralias "domain\user" -SecondaryOwnerAlias "<domain\user>"

Change site collection administrators for all site collections
We can just pipe them together to set site collection primary and secondary administrators for all sites in a web application

Get-SPWebApplication "" | Get-SPSite -Limit All | ForEach-Object { Set-SPSite $_ -OwnerAlias "<domain\user>" -SecondaryOwnerAlias "<domain\user>" }

This will change SharePoint 2010 primary site collection administrator and secondary site collection administrator. Related Post: Add Site Collection Administrators Programmatically in SharePoint

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...