Wednesday 30 April 2008

Working with SharePoint Groups

This is a nice article that talks about working with SharePoint groups programmatically.

The only problem I had was I had to replace the lines
SPRoleDefinitionBindingCollection roleDefBindings = roleAssignment.RoleDefinitionBindings;

with SPRoleDefinition and added this role definition directly to the SPweb as shown below

SPRoleAssignment roleAssignment = new SPRoleAssignment((SPPrincipal)group);
def = web.RoleDefinitions["Full Control"];
roleAssignment.RoleDefinitionBindings.Add(def);
web.RoleAssignments.Add(roleAssignment);
web.Update();

http://www.emptycache.com/blog/2008/04/18/working-with-users-and-groups-in-sharepoint-2007/

No comments: