Pergunta

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
}
Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top