Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

How can I get group members?

  Asked By: Cedric    Date: Mar 24    Category: Sharepoint    Views: 2142

I'm making some codes in web parts.

When the group owner logs in, he wants to see the his group members
lists in a page to delete or edit member information.

// The user logged in as a group owner
string loginName = SPContext.Current.Web.CurrentUser.LoginName;
SPUser spuser = SPContext.Current.Web.Users[loginName];
SPGroupCollection spgroups = spuser.OwnedGroups;

then how can I get his members? I'm struggling with this.
Any help?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Aditiya Kapale     Answered On: Mar 24

Is something like this what you are looking for:

SPUser currentUser = SPContext.Current.Web.CurrentUser;
foreach (SPGroup group  in currentUser.OwnedGroups)
{
foreach (SPUser user  in group.Users)
{
// do something
Response.Write("<p>" + user.Name + "</p>");
}
}

 
Didn't find what you were looking for? Find more on How can I get group members? Or get search suggestion and latest updates.




Tagged: