zaterdag 5 november 2011

Get Site description


In this function you receive the description of a Site using the SharePoint 
Webservice Webs.asmx .  

    private string GetSiteDescription(string siteurl)
    {
        SetStatus("Initialize webservice...");
        string siteDesc = "";
         // 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)
            {
                siteDesc = myNode.Attributes["Description"].Value;
            }
        }
        catch (Exception exception1)
        {
            MessageBox.Show(exception1.Message, "Error loading SiteName", MessageBoxButtons.OK);
            this.SetStatus("Error loading site Name info");
        }
        finally
        {
            webs.Dispose();
        }
        return siteDesc;
    }

 

Geen opmerkingen:

Een reactie posten