SPWeb.AssociatedMemberGroup returning incorrect information.

Just recently, I’ve been working on a solution for a client that wanted to create a meetings portal for a very formal meeting process. The basic breakdown of the site is as follows, A top level Site Collection housing http://meetings.contoso.com.

This site was created with the default groups of Meetings Visitors, Members and Owners. Then for each particular committee, there was a sub-web with Unique  permissions, thus ensuring separation of the committees and ensuring  that access was given to the correct groups.


Under each subweb, Meeting workspaces are created for each of the monthly meetings and the following process is followed:-

  1. Meeting organiser uploads Meeting minutes and supporting documents.
  2. Workflows triggered inviting comment from the members group.
  3. Members update with comments
  4. Comments are approved/rejected and the content agreed.
  5. Site is locked down as Read Only for the AssociatedMembers group

As you can see from the above, steps 1-4 are fairly standard out of the box SharePoint behaviours. The problem comes in Step 5. Not because we’re doing anything strange with security, but because we’re not doing it through the UI. Rather the client requirements were to provide a meeting management webpart that included an option to lock the site down through some custom code once certain attributes were valid.

To verify the correct behaviour as experienced through the UI,  navigate to the /Commitee2/Mtg1 subweb and choose Site Actions/Site permissions, you’ll see the usual UI page showing you that the site is “Inheriting it’s permissions from it’s parent (Committee2)” and underneath this warning, you’ll see Committee2 Owners, Members and Visitors. This is as we’d expect.

The problem comes in the custom code for the site which breaks inheritance and then resets the permissions for each of the groups. The groups are obtained from the SPWeb object for the current site from context.

SPWeb currWeb = SPContext.Current.Web;

string associatedMemberGroupName = currWeb.AssociatedMemberGroup;
string associatedOwnerGroupName = currWeb.AssociatedOwnerGroup;
string associatedVisitorGroupName = currWeb.AssociatedVisitorGroup;

When stepping through the code, I expected these objects to whole values similar to “Committee2 Members Group” which should be the value inherited from the Parent. Instead, I’m receiving “Meetings Members Group” which is the Site Collection root group, completely ignoring the inheritance of the Parent.

Bizarrely, if you instantiate an SPWeb against currWeb.ParentWeb and look at the same groups, you get the values that you’d expect.


In Summary:-

Instantiating SPWeb.AssociatedMemberGroup does not return the value expected when inheritance is broken even when existing values are copied.


It may be possible to look at the ParentWeb object and use it’s values instead, however this is very Situation specific!


Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.