This is the method that get all the team sites available and extract following properties:
- ID
- Title
- Url
- Description
- Members
- Administrators
- Type
public List<WorkRoom> GetAllAvaliableRooms(string sealedRoomAccountName, string everyoneGroupName, bool loadMembers, string rootSiteUrl)
{
try
{
List<WorkRoom> result = new List<WorkRoom>();
SPSecurity.RunWithElevatedPrivileges(delegate ()
{
SPSite site = new SPSite(rootSiteUrl);
SPWebApplication webApplication = site.WebApplication;
SPSiteCollection siteCollections = webApplication.Sites;
foreach (SPSite siteCollection in siteCollections)
{
SPWeb rootWeb = siteCollection.RootWeb;
if (String.Equals(rootWeb.Url, rootSiteUrl, StringComparison.InvariantCultureIgnoreCase))
continue;
if (!String.Equals(rootWeb.WebTemplate, TEAM_SITE_TEMPLATE_NAME, StringComparison.InvariantCultureIgnoreCase))
continue;
var workRoom = new WorkRoom()
{
ID = siteCollection.ID,
Title = rootWeb.Title,
Url = siteCollection.Url,
Description = rootWeb.Description,
Members = loadMembers ? WorkRoomHelper.GetMembers(rootWeb) : new List<User>(),
Administrators = WorkRoomHelper.GetAdministrators(rootWeb),
Type = WorkRoomHelper.GetRoomType(rootWeb, sealedRoomAccountName, everyoneGroupName)
};
result.Add(workRoom);
}
});
return result;
}
catch (Exception ex)
{
throw new FaultException<UnexpectedServiceFault>(new UnexpectedServiceFault()
{
ErrorMessage = ex.Message,
StackTrace = ex.StackTrace,
FriendlyErrorMessage = "There was an errpr when getting the list of available sites"
});
}
}
Is this helpfull?
Regards
Americo