Create DefaultSharepoint Groups


I am recently trying to create site collection using Admin Web Service. When site creating using admin web service, share point not creating default share point groups. You have to write custom code to create share point default groups. The following is the code to create default sp groups.

public bool CreateDefaultSPGroups(string url)
    {
        bool isGroupsCreated = false;
        try
        {
            using (SPSite site = new SPSite(url))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    web.CreateDefaultAssociatedGroups(site.Owner.LoginName, site.SecondaryContact.LoginName, string.Empty);
                    isGroupsCreated = true;
                }
            }
        }
        catch (Exception ex)
        {
            isGroupsCreated = false;
  }
        return isGroupsCreated;
    }

Comments

Popular posts from this blog

Windows Azure Package Build Error: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

Resource ID : 1. The request limit for the database is 180 and has been reached.

Update Excel Sheet using C#, Where Excel not Installed on Server