peter
peter

Reputation: 445

Is it possible to set who's the site owner when a new site is created programmatically? (SharePoint)

I am creating sites programmatically in a web part and I wonder if it's possible to set who the site owner is? By default the one who creates the site is the owner but I am going to use this web part for a customer and I don't want to be the owner of the sites. Do I have to change this afterwards or is it possible to set when the site is created?

Thanks in advance.

Upvotes: 0

Views: 1161

Answers (2)

Rich Bennema
Rich Bennema

Reputation: 10335

If you are creating a site collection, use djeeg's suggestion. If you are creating a subsite, permissions will be inherited from the parent site by default unless you call BreakRoleInheritance. If that is the case, you can create a new group, assign it to the AssociatedOwnerGroup property, and then add the appropriate users to that group.

Upvotes: 0

djeeg
djeeg

Reputation: 6765

The SPSite constructor takes the owner parameters right, can you just change that to who you want it to be?

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spsitecollection.add.aspx

Upvotes: 2

Related Questions