In this function you receive the Name of a Site based on the Site Url, this using the SharePoint
Webservice Webs.asmx
private string GetSiteName(string siteurl)
{
SetStatus("Initialize webservice...");
string siteName = "";
// 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.GetWeb(siteurl);
if (myNode != null)
{
// only add sites that starts with the given site url
siteName = myNode.Attributes["Title"].Value;
}
}
catch (Exception exception1)
{
MessageBox.Show(exception1.Message, "Error loading SiteName", MessageBoxButtons.OK);
this.SetStatus("Error loading site Name info");
}
finally
{
webs.Dispose();
}
return siteName;
}
Geen opmerkingen:
Een reactie posten