Get SharePoint Site Collection (Code)

private static Dictionary GetSites()
{
Dictionary sites = new Dictionary(32);



WSSModule.WebAppOp(
delegate(SPWebApplication webapp)
{
foreach (SPSite site in webapp.Sites)
{
try
{

using (SPWeb web = site.RootWeb)
{
if (web.DoesUserHavePermissions(SPBasePermissions.ViewPages))
sites.Add(web.ServerRelativeUrl, web.Title);
}

} catch(SPException)
{

}
}
}
);


return sites;

}

Comments