So, one of the things I skipped over in my last post was just how you get the MembershipGroupID for the group you want the users to administer. Well, there are lots of options – all you’ve got to do is get to your page with the ListView with the correct value for the GET parameter MembershipGroupId.
If you knew the ID in advance, you could hard code it. I didn’t, so I used a redirect page. My page accepts a GET parameter of ‘OWNERS’, ‘VISITORS’, or ‘MEMBERS’ and redirects to the ‘list users’ page with the correct group ID. Again, I wrote this page in visual studio as code behind page to go in the _layouts directory.
protected void Page_Load(object sender, EventArgs e)
string group = Request.QueryString["group"];
SPWeb web = SPContext.Current.Web;
int igroup = web.AssociatedMemberGroup.ID;
if (group != null)
if (group.ToUpper() == "OWNERS")
igroup = web.AssociatedOwnerGroup.ID;
else if (group.ToUpper() == "VISITORS")
igroup = web.AssociatedVisitorGroup.ID;
SPUtility.Redirect("SimpleUG/ListUsers.aspx?MembershipGroupId=" + igroup, SPRedirectFlags.RelativeToLayoutsPage, this.Context);
That’s all there is too it – it get’s the ‘associated’ group for the web. You could do whatever you want here, though – look up specific groups by name, permission level, as specified elsewhere, whatever. I then built into the navigation of my site links to things like:
which would resolve the ID of the Owners group, and forward the user to a list of the users in that group.