kamagra how much to take

Removing Role Definitions from a Role Assignment

Role assignments can be exposed ala ISecurableObject and pretty much everything, in order to support Securable Objects (for item level security,etc.), is an ISecurableObject in SharePoint 2007. So, to begin with, we are going to use ISecurableObject to get assignments in combination with a SPPrincipal (representing a user or group)  via the GetAssignmentByPrincipal method available off a RoleAssignments collection (it doesn’t even require casting!).

  1. SPRoleAssignment assignment =  ISecurableObject.RoleAssignments.GetAssignmentByPrincipal(SPPrincipal);

Following, a new SPRoleAssignment object is hydrated based on the SPPrincipal object, and that SPRoleAssignment object has a RoleDefinitionBindings collection that exposes the Remove method. Therefore, if you had an array or typed collection of SPRoleDefinitions you wanted to iterate, you could do something like (of course after testing whether the SPRoleAssignment object created is not null):

  1. foreach (SPRoleDefinition definition in List<SPRoleDefinition>)
  2. {
  3. assignment.RoleDefinitionBindings.Remove(definition);
  4. }

Gone! :)

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>