Geeks With Blogs
Wayne Magnum's Blog

The below code demonstrates how you can assign a SharePoint Group to a SharePoint site  using the SharePoint object model.

SPSite spsite = new SPSite("Site_Name");
     using (SPWeb web = spsite.OpenWeb())
          web.AllowUnsafeUpdates = true;
          SPGroup sgrp = web.SiteGroups["Group_Name"];
          SPRoleDefinition roleDefinition = web.RoleDefinitions.GetByType(SPRoleType.Reader);
          SPRoleAssignment roleAssignment = new SPRoleAssignment((SPPrincipal)sgrp);
catch (Exception ex)



Posted on Friday, January 21, 2011 1:24 PM SharePoint 2007 | Back to top

Comments on this post: How to assign an exiting SharePoint group to a site using the SharePoint object model?

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Wayne H Magnum | Powered by: | Join free