Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to show members and owners in a webpart. My site collection can be created in different languages, so I can't get needed groups like web.Groups["Contoso Members"]. Because it may be "Medlemmar på Contoso" or something else.

When I ran $web.Groups I saw Members group had id 5.

Can I trust this id number? Or is it random number?

SPGroup members = web.Groups[5]
foreach (SPUser user in members.Users)
{
   //show it
}
share|improve this question

1 Answer 1

up vote 5 down vote accepted

You can't count on that number, as it's just the index within the collection.

The AssociatedMemberGroup and AssociatedOwnerGroup properties on SPWeb should give you what you're looking for without having to know the actual name of the group.

share|improve this answer
    
Thank you very much. It is exactly what I needed! –  Anatoly Mironov Jul 25 '11 at 13:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.