Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The following is the sample code snippet for how to differentiate workspace site and team site. Also this code list out all the workspace site in the server.
SPGlobalAdmin globalAdmin = new SPGlobalAdmin();
//Get all the virtual servers.
foreach(SPVirtualServer objVirtualServer in globalAdmin.VirtualServers)
{
//if the site is ready - (already extended SPS web site)
if (objVirtualServer.State == SPVirtualServerState.Ready)
{
ServerAndSitesInfo info = new ServerAndSitesInfo();
info.isVirtualServer = true;
info.spweb = null;
info.url = objVirtualServer.Url.ToString();
info.title = objVirtualServer.Description;
arrSitesAndSubsites.Add(info);
showWorkspaces = showWorkspaces.ToLower();
//Loop thro' the sites
foreach (SPSite spsite in objVirtualServer.Sites)
{
foreach(SPWeb spweb in spsite.AllWebs)
{
try
{
if(spweb.WebTemplateId == 1 ||
(spweb.WebTemplateId == 2 && showWorkspaces == "yes")) ////2 = Meetings, Invalid =
-1, 1=Team Site
{
info = new ServerAndSitesInfo();
info.isVirtualServer = false;
info.spweb = spweb;
info.url = spweb.Url.ToString();
info.title = spweb.Title;
arrSitesAndSubsites.Add(info);
}
}
catch{}
}
}
}
}
Keep coding :)