Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Application needs to be able to list subsites

  Asked By: Coty    Date: Oct 27    Category: Sharepoint    Views: 1035

We want to be able to get a list of all subsites under
a given site. The tricky part is that we need to be
able to do this under the security context of a user
who has Site Contributor privileges for the given
site, but has no more privileges than that. Below is
the code that we are using. The code works fine if
the user is a Site Collection Owner but we don't want
to give those privileges, so we are trying to pass the
credentials of a privileged user as you can see below.
However, we get an access denied error on the line
(the SpWebCollection function call ie SPWebCollection
cltSubSites = cltSites.AllWebs). It therefore appears
to us that the credentials are either not being passed
properly or for some reason are not being accepted by
the server.

private bool isSiteExist(string strCurrentURL)

string strURL = "http://ServerName";
string strUserName = "MyUserName";
string strPassword = "MyPassword";
string strDomain = "Pivotal";

WebRequest myWebRequest=WebRequest.Create(strURL);
CredentialCache myCache = new CredentialCache();
myCache.Add(new Uri(strURL),"NTLM", new
myWebRequest.Credentials = myCache;

SPGlobalAdmin objGAdmin = new SPGlobalAdmin();
SPVirtualServer objVServer =
SPSiteCollection cltSiteCollections =

foreach(SPSite cltSites in cltSiteCollections)
SPWebCollection cltSubSites = cltSites.AllWebs;
foreach (SPWeb objWeb in cltSubSites)
if(objWeb.Url.ToLower() ==
return true;
return false;

Can I get any workaround or resolution on this?



No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on Application needs to be able to list subsites Or get search suggestion and latest updates.