Easy Way To Add Role Assignments
I have to do this all the time. If you have a similar requirement, just use the following method:
C#:
-
public static void AddRoleAssignment(ISecurableObject securable, SPPrincipal principal, SPRoleDefinition[] roleDefinitions)
-
{
-
foreach (SPRoleDefinition definition in roleDefinitions)
-
{
-
roleDefinitionBindings.Add(definition);
-
}
-
roleAssignment.ImportRoleDefinitionBindings(roleDefinitionBindings);
-
securable.RoleAssignments.Add(roleAssignment);
-
}
The usage of it is pretty straightforward, you have an ISecurableObject parameter to expose role assignments for an object, an SPPrincipal to represent a user or group, and a SPRoleDefinition array to act as a container for role definitions.
Related posts:
- Removing Role Definitions from a Role Assignment
- SharePoint Security Helper Class
- Display A SharePoint Users Role Collection
- ADAM (Active Directory In Application Mode) Custom Role Provider
- Comparing SPPrincipal Objects To See If Same Member
No Comments »
No comments yet.
RSS feed for comments on this post. TrackBack URL























Articles & Research
SharePoint Architecture
Research Methodology
Personal/Off-Topic
Article Or Research Filed Under 
