Search code examples
c#sharepointpermissionsmosswindows-sharepoint-services

Copy permissions from one user to another user - SharePoint


I want to copy the permissions of a user and to another user. I know i can do it by creating a group with required permissions and adding the users will do it. But i dont want to create a group. Is there a way to copy the permissions of a user to another user directly?

NLV


Solution

  • You need to write code that will;

    1. Check if the current site inherits permissions or sets its own
    2. From the site that sets permissions (self or ancestor, depending on 1) go over the RoleAssignments collections
    3. For each role assignment check if your source user is specified
    4. If so, create a role assignment for the target user

    This code must run under administrative privileges (RunWithElevatedPrivilegese will suffice if written as web part)