Compartir a través de


Clase ServerContext

Proporciona métodos de tiempo de ejecución para los servicios compartidos de Microsoft Office SharePoint Server 2007. Esta clase o este miembro está en desuso. Cuando actualice o escriba aplicaciones nuevas que utilicen esta clase o miembro, use la clase o el miembro nuevo. En su lugar, utilice SPServiceContext .

Jerarquía de la herencia

System.Object
  Microsoft.Office.Server.ServerContext

Espacio de nombres:  Microsoft.Office.Server
Ensamblado:  Microsoft.Office.Server (en Microsoft.Office.Server.dll)

Sintaxis

'Declaración
Public NotInheritable Class ServerContext
'Uso
Dim instance As ServerContext
public sealed class ServerContext

Ejemplos

//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());
            }
        }
    }
}

Seguridad para subprocesos

Los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para subprocesos. No se garantiza que los miembros de instancias sean seguros para los subprocesos.

Vea también

Referencia

Miembros ServerContext

Espacio de nombres Microsoft.Office.Server