Monday, 11 June 2012

Get All users in Active directory through Visual Webpart - Sharepoint 2010

using (SPSite site = new SPSite(SPContext.Current.Site.Url))
{
SPWebApplication webApp = site.WebApplication;
foreach (SPSite sitecol in webApp.Sites)
{
SPWebCollection webs = sitecol.AllWebs;
foreach (SPWeb web in webs)
{
SPUserCollection users = web.SiteUsers;
foreach (SPUser user in users)
{
//code
}
}
}
}

No comments:

Post a Comment