ServerContext-Klasse

Enthält Laufzeitmethoden für gemeinsame Dienste in Microsoft Office SharePoint Server 2007. Diese Klasse bzw. dieses Mitglied ist veraltet. Wenn Sie neue Anwendungen aktualisieren oder schreiben, die diese Klasse bzw. dieses Mitglied verwenden, verwenden Sie stattdessen die neue Klasse bzw. das neue Mitglied. Verwenden Sie stattdessen SPServiceContext .

Vererbungshierarchie

System.Object
  Microsoft.Office.Server.ServerContext

Namespace:  Microsoft.Office.Server
Assembly:  Microsoft.Office.Server (in Microsoft.Office.Server.dll)

Syntax

'Declaration
Public NotInheritable Class ServerContext
'Usage
Dim instance As ServerContext
public sealed class ServerContext

Beispiele

//Updates a user profile
//Creates a user profile. Obtains the property values from the default 
//domain controller or the master connection that is configured on the 
//server
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint.Administration;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;
using Microsoft.Office.Server;
using System.Web;

namespace UserProfilesApp
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                using (SPSite site = new SPSite("https://servername"))
                {
                    ServerContext context = ServerContext.GetContext(site);
                    UserProfileManager profileManager = new UserProfileManager(context);
                    string sAccount = "domainname\\username";
                    UserProfile u = profileManager.GetUserProfile(sAccount);
                    u[PropertyConstants.HomePhone].Value = "nnnnnnnnnn";
                    u[PropertyConstants.CellPhone].Value = "nnnnnnnnnn";
                    u.Commit();
                }
            }
            catch (UserNotFoundException exception)
            {
                Console.WriteLine(exception.ToString());
            }
        }
    }
}

Threadsicherheit

Alle öffentlichen static (Shared in Visual Basic) Member dieses Typs sind threadsicher. Die Threadsicherheit von Instanzmembern ist nicht gewährleistet.

Siehe auch

Referenz

ServerContext-Member

Microsoft.Office.Server-Namespace