Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.50 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Adding existing security group to a subsite
  2. SPWeb currentSite = SPContext.Current.Web;
  3.                 currentSite.EnsureUser(groupOwner);
  4.                 currentSite.SiteGroups.Add(siteTitle1, currentSite.SiteUsers[groupOwner],
  5.                 currentSite.SiteUsers[groupOwner], siteDescription1);
  6.        
  7. var subWeb = currentSite.Webs["MySubSite"];
  8.        
  9. subWeb.EnsureUser(groupOwner);
  10. subWeb.SiteGroups.Add(siteTitle1, currentSite.SiteUsers[groupOwner],
  11.             subWeb.SiteUsers[groupOwner], siteDescription1);