In this function you receive a ArrayList containing all Sites/SubSites of a SiteCollection using
the SharePoint Webservice Webs.asmx .
private ArrayList GetSites(string siteurl)
{
SetStatus("Initialize webservice...");
ArrayList myList = null;
// reading al the sites and subsites via webservice
WS_Webs.Webs webs = new WS_Webs.Webs();
if (chk_DefaultLoggin.Checked)
webs.Credentials = System.Net.CredentialCache.DefaultCredentials;
else
{
webs.PreAuthenticate = true;
webs.Credentials = new System.Net.NetworkCredential(txt_UserID.Text, txt_PassWord.Text, txt_domain.Text);
}
webs.Url = siteurl + @"/_vti_bin/webs.asmx";
try
{
XmlNode myNode = webs.GetAllSubWebCollection();
XmlNodeList nodes = myNode.SelectNodes("*");
foreach (XmlNode node in nodes)
{
// only add sites that starts with the given site url
if ( node.Attributes["Url"].Value.StartsWith(siteurl))
myList.Add(node.Attributes["Url"].Value);
}
}
catch (Exception exception1)
{
MessageBox.Show(exception1.Message, "Error loading siteinfo", MessageBoxButtons.OK);
this.SetStatus("Error loading site info");
}
finally
{
webs.Dispose();
}
}
Geen opmerkingen:
Een reactie posten