16.01.2013 Views

Microsoft Sharepoint Products and Technologies Resource Kit eBook

Microsoft Sharepoint Products and Technologies Resource Kit eBook

Microsoft Sharepoint Products and Technologies Resource Kit eBook

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

934 Part IX: Maintaining a Server in Windows SharePoint Services<br />

Web services provide their functionality through the _vti_bin virtual directory,<br />

which maps to the :\Program Files\Common Files\<strong>Microsoft</strong><br />

Shared\Web Server Extensions\60\ISAPI directory in the server.<br />

The Alerts Service<br />

The Alerts service provides methods for working with alerts for list items in a Share-<br />

Point site. This code example will show you how to create a simple Windows form<br />

that uses the GetAlerts method of the Alerts Web service to retrieve information<br />

about alerts within a SharePoint site.<br />

First we have to create a new Window Application project <strong>and</strong> add a reference<br />

to the Alerts Web service, that is http://servername/_vti_bin/alerts.asmx. We will<br />

drag a label <strong>and</strong> a button onto the form <strong>and</strong> add the following code in the button<br />

click event h<strong>and</strong>ler. This code will first declare <strong>and</strong> initialize a variable for the Alerts<br />

Web service, that we have called in our example WebAlerts. Next we have to<br />

authenticate the current user by passing the default credentials to the Alerts Web service<br />

from the system credential cache. Then we can use the GetAlerts method to get<br />

all the alerts on this SharePoint site. The following information will be displayed in<br />

the label control: the name of the server, the URL of the server, the title of the Share-<br />

Point site, <strong>and</strong> the number of alerts that are made on the SharePoint site.<br />

WebAlerts.Alerts alertService = new WebAlerts.Alerts();<br />

alertService.Credentials = System.Net.CredentialCache.DefaultCredentials;<br />

WebAlerts.AlertInfo allAlerts = alertService.GetAlerts();<br />

label1.Text = "Server: " + allAlerts.AlertServerName +<br />

"\nURL: " + allAlerts.AlertServerUrl +<br />

"\nWeb Title: " + allAlerts.AlertWebTitle +<br />

"\nNumber: " + allAlerts.Alerts.Length.ToString();<br />

<strong>Microsoft</strong>.SharePoint.Utilities Namespace<br />

The <strong>Microsoft</strong>.SharePoint.Utilities namespace is used for various utilities purposes,<br />

including encoding of strings <strong>and</strong> processing of user information. This namespace can<br />

be found in the Windows SharePoint Services assembly (in <strong>Microsoft</strong>.SharePoint.dll).<br />

Table 33-6 shows the classes of the <strong>Microsoft</strong>.SharePoint.Utilities namespace.<br />

Table 33-6 Classes in the <strong>Microsoft</strong>.SharePoint.Utilities Namespace<br />

Name Description<br />

SPEncode Provides methods for encoding strings<br />

SPPropertyBag Stores arbitrary key-<strong>and</strong>-value pairs that contain custom property settings<br />

SPUtility Provides tools for converting date <strong>and</strong> time formats, for getting information<br />

from user names, for securing access to sites, <strong>and</strong> for various other tasks in<br />

managing a deployment of Windows SharePoint Services

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!