Thursday, June 23, 2011

RoleDefinition and RoleAssignments

The concept is pretty simple. You have users who you want to assign unique permissions on your web site. You create a RoleDefinition where you specify the unique permissions that make up the role that you want to create [say you were defining the contribute role], and also give a unique name for the role definition.

Then you'd create a RoleAssignment object. This is a object that takes in

  1. The user that you want to associate with the RoleDefinition above
  2. In the RoleDefinitionBindings collection, you add one or more RoleDefinitions that you want to associate with the user - like Reader, Contributor etc. This is where you would add in the new RoleDefinition object that you created above.
  3. Add this RoleAssignment object to the collection obtained from SPWeb.RoleAssignments
I'll try to illustrate this tomorrow by adding a diagram that shows how it all comes together

No comments:

Post a Comment