Recently I have developed a web application to interact with SharePoint. Its objective was to hide the SharePoint UI to the final users in order to they can administer the site collection without any knowledge of SharePoint. Users have rights to manage users and groups but we wanted that they did not navigate through the administration pages of the site. For that reason the web application uses the API to do all the operations. At the moment the most complex operation has been the "add new group" due his poor documentation. This is the code that I have used to accomplish this operation: //Add the group to the SPWeb web //Associate de group to the SPWeb. Now it will display in the quick launch bar //Assignment of the roles.
web.SiteGroups.Add(groupName, owner, defaultuser, description);
web.AssociatedGroups.Add(web.SiteGroups[groupName);
web.Update();
SPRoleAssignment assignment = new SPRoleAssignment(web.SiteGroups[groupName]); SPRoleDefinition roleApp = web.RoleDefinitions["Aprobar"]; assignment.RoleDefinitionBindings.Add(roleApp);
SPRoleDefinition roleCol = web.RoleDefinitions["Colaborar"]; assignment.RoleDefinitionBindings.Add(roleCol);
Thursday, September 27, 2007
Add a new SPGroup programmatically to SharePoint
Publicado por
Àlex
en
3:57 AM
Subscribe to:
Post Comments (Atom)
2 comentarios:
Hi,
I just wanted to make sure if it is possible to add an SPGroup which was created in a web to another web.I tried this manually and it works.Can u suggest a way to do this programmatically.How to retreive all the SPGroups existing in a site collection???
Thanx
hi,
i wanna know if i have a list of courses beside it a check box i wanna know when a user check a course (each course has 2 groups)
so when he check a course his name is added to the group
so how can i add the user to an existing group programmatically???
thanx in advance
Post a Comment