Método ServerContext.GetContext (SPSite)
Obtém a instância ServerContext T:Microsoft.Office.Server.ServerContext para o site especificado.
Espaço para nome Microsoft.Office.Server
Conjunto de Módulos (Assembly) Microsoft.Office.Server (em microsoft.office.server.dll)
A sintaxe
Public Shared Function GetContext ( _
site As SPSite _
) As ServerContext
Dim site As SPSite
Dim returnValue As ServerContext
returnValue = ServerContext.GetContext(site)
public static ServerContext GetContext (
SPSite site
)
Parâmetros
- site
Um objeto Microsoft.SharePoint.SPSite T:Microsoft.SharePoint.SPSite.
Retornar valor
Uma instância ServerContext T:Microsoft.Office.Server.ServerContext.
Exemplo
//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());
}
}
}
}
Consulte também
Referência
ServerContext De classe
ServerContext Membros
Microsoft.Office.Server De espaço para nome