Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>when 'cloning' a SharePoint security group its first of all not about the group itself but about the permissions.</p> <p>These permissions are stored as roleassignments to a SPWeb object. First you must find the group that you want to clone by doing:</p> <pre><code>SPGroup group = spWeb.Groups["name group"]; </code></pre> <p>Then you must use this retrieved group to get the roleassignments on the SPWeb object.</p> <pre><code>SPRoleAssignment ass = spWeb.RoleAssignments.GetAssignmentByPrincipal(group2); </code></pre> <p>Then you must simply create a new SPGroup and add the group to the roleassignment and the roleassignment to the web object:</p> <pre><code>spWeb.SiteGroups.Add(groupName, user, user, groupDescription); SPGroup newGroup = spWeb.SiteGroups[groupName]; SPRoleAssignment roleAssignment = new SPRoleAssignment(newGroup); //add role to web spWeb.RoleAssignments.Add(roleAssignment); spWeb.Update(); </code></pre> <p>After this you should have a new group with the same permissions as the original group.</p> <p>If you're not doing the above in a sharepoint feature or something you can do it from a console application. Just create a console application in VS and fill it with something like this:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint; namespace ConsoleApplication { class Program { static void Main(string[] args) { using (SPSite spSite = new SPSite("http://yoururl")) { using (SPWeb spWeb = spSite.RootWeb) { //perform the code to clone the group here } } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload