Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a list of all users in SharePoint

Tags:

c#

sharepoint

How to get a list of all users in a certain group in SharePoint by code?

like image 925
Ahmad Farid Avatar asked Aug 12 '09 14:08

Ahmad Farid


1 Answers

using (SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
{
    SPGroupCollection collGroups = oWebsite.Groups;
    foreach (SPGroup oGroup in collGroups)
    {
        foreach(SPUser oUser in oGroup.Users)
        {
           Response.Write(oUser.Name);
        }
    }
}
like image 53
Sachin Avatar answered Sep 20 '22 17:09

Sachin