Showing posts with label create site. Show all posts
Showing posts with label create site. Show all posts

October 1, 2007

MOSS: SPWeb.SiteGroups vs. SPWeb.Groups

Problem:
When creating a site and adding groups to it programmatically, I add groups to the new site's SiteGroups collection like this:

newSite.SiteGroups.Add(grpOwnersName, currentUser, currentUser, grpOwnersName);

Then I'd like to define some properties of the new group, and I try to do this:

grpOwners = newSite.Groups[grpOwnersName];

Oh no, the Groups collection is empty! How and when is it populated?

Workaround:
Of course I can use SiteGroups, but I'd very much like to use Groups collection since there are zillions of groups in the SiteGroups collection, and I'm a performance freak.

grpOwners = newSite.SiteGroups[grpOwnersName];

Solution:
Unknown