I am unable to access the sharepoint users and groups using below code to access all the users and groups of site collections of web application including their sub-sites and child sub-sites
Can any one do let me know what's wrong in my below code and how can I solve it
Guid siteId = SPContext.Current.Site.ID;
SPSecurity.RunWithElevatedPrivileges(delegate(){
try
{
using (SPSite _site = new SPSite(siteId))
{
SPSiteCollection tmpRootColl = _site.WebApplication.Sites;
foreach (SPSite tmpSite in tmpRootColl)
{
// using (SPWeb elevatedWeb = _site.OpenWeb(CurrentWeb.ID))
//foreach (SPWeb elevatedWeb in _site.AllWebs)
foreach (SPWeb elevatedWeb in tmpSite.AllWebs)
{
}
}
}
}