Welcome to MSDN Blogs Sign in | Join | Help

WSS 2.0 : How to differentiate workspace site and team site.

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 :)

 

Published Wednesday, December 13, 2006 2:09 PM by Karthikeyan
Filed under:

Comments

No Comments

Anonymous comments are disabled
 
Page view tracker