Thursday, January 7, 2010

Creating default Security Groups for new site collection

Everyday in SharePoint makes you learn something new...this is very true

Al though it is a very small issue and most of us might be knowing this but still thought of sharing with community. In my current assignment we are provisioning SharePoint sites using Workflows and Workflow activities.

I have a list that is used to record a request for new site collection,  i have also developed a custom Visual Studio workflow that contains one custom workflow activity to create a new site collection. My list contains a field that accepts Site Template based on which the new site collection gets created.

Till now everything looks good, but when i create a site based on Team Site through code my new site collection looked different then when it is created using central admin.

It just had one security group where as when we create site using same site template using central admin we can see three groups

1. Site Members

2. Site Owners

3. Site Viewers

After googling around i came to know that apart from provisioning site, SharePoint central admin makes some method calls to provision default security group.

SPSite.CreateDefaultAssociatedGroup(string PrimaryOwnerLogin, string SecondaryOwnerLogin, string GropuPrefix)

This method call will make default security groups (Members, Owners, Visitors) for your new site collection with all the required permissions.

This method is called automatically by SharePoint central admin.


Sudhir Kesharwani