Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Enumerate Sites

  Asked By: Dario    Date: Apr 17    Category: Sharepoint    Views: 975

This is probably an easy question. We have a WSS only server with a
managed path of http://teams/sites/. How could I enumerate all these
top-level sites via the WSS object model (preferably VB.NET) in
order to build a site directory? A little more challenge would be
only displaying the sites the current user has access to at least



2 Answers Found

Answer #1    Answered By: Monte Cooley     Answered On: Apr 17

Here is a start:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user  code to initialize the page here
Dim mySite3 As SPSite = SPControl.GetContextSite(Context)
Dim myWeb As SPWeb = mySite3.AllWebs("")

Dim strServer As String
Dim strServer2 As String
Dim globalAdmin As New SPGlobalAdmin
strServer = myWeb.Url & "/sites/atisd"
Dim strCheckSSL As String = Request.ServerVariables("HTTPS")
If InStr(strCheckSSL, "off") Then
strServer2 = "http://" & Request.ServerVariables("SERVER_NAME")
& ":" & Request.ServerVariables("SERVER_PORT") & "/sites"
strServer2 = "https://" & Request.ServerVariables("SERVER_NAME")
& ":" & Request.ServerVariables("SERVER_PORT") & "/sites"
End If
Dim strSVC As String = ConfigurationSettings.AppSettings("svcAcct")
Dim strDomain As String =
Dim relativePath As String

relativePath = "" ' Show current  Folder
Dim strPSWRD As String =
Dim ss As Integer = 0
If impersonateValidUser(strSVC, strDomain, strPSWRD) Then
'Insert your code that runs under the security context of a
specific user here.

Dim uri As New System.Uri(strServer2)
Dim virtualServer As SPVirtualServer =
Dim siteCollections As SPSiteCollection = virtualServer.Sites
Dim siteCollection As SPSite
Dim dirName As String
For Each siteCollection In siteCollections
If InStr(siteCollection.Url, "/_catalogs/") < 1 Then
If ss < 1 Then
dirName = "" & Mid(siteCollection.Url,
InStrRev(siteCollection.Url, "/") + 1)
CreateNodes(dirName, dirName)
ss += 1
End If
End If

Next siteCollection
'Your impersonation failed. Therefore, include a fail-safe
mechanism here.
Response.Write("Impersonation Failed!!")
End If
End Sub

You will have to wrtite the code for CreateNodes()

Answer #2    Answered By: Guadalupe Bullock     Answered On: Apr 17

This appears to be exactly what I need. I'll work
with it and see what I can do.

Didn't find what you were looking for? Find more on Enumerate Sites Or get search suggestion and latest updates.