Scenario:
You want to add certain users/group as a part of site creation.
SPWeb web = SPContext.Current.Web;Usage:
SPRoleDefinition role = site.RoleDefinitions["Contribute"];
// Adding User Groups
SPRoleAssignment roleAssignmentGroup;
roleAssignmentGroup = new SPRoleAssignment(@"Training\ConsumerGroup","consumers@training.com","All Consumers of the website","Notes about Consumer Group");
roleAssignmentGroup.RoleDefinitionBindings.Add(role);
web.RoleAssignments.Add(roleAssignmentGroup);
// Adding specific users
SPRoleAssignment roleAssignmentUser;
roleAssignmentUser = new SPRoleAssignment(@"TRAINING\SandeepK","sandeep@training.com","Sandeep Nahta","Notes:SharePoint Consultant");
roleAssignmentUser.RoleDefinitionBindings.Add(role);
web.RoleAssignments.Add(roleAssignmentUser);
Provisioning Feature Activation , Console Application
0 comments:
Post a Comment