ServerContext - Classe
Fournit des méthodes d'exécution pour les services partagés de Microsoft Office SharePoint Server 2007. Cette classe ou ce membre est déconseillé. Lorsque vous mettez à niveau ou écrivez de nouvelles applications qui utilisent cette classe ou ce membre, utilisez la nouvelle classe ou le nouveau membre à la place. Utilisez plutôt SPServiceContext .
Hiérarchie d’héritage
System.Object
Microsoft.Office.Server.ServerContext
Espace de noms : Microsoft.Office.Server
Assembly : Microsoft.Office.Server (dans Microsoft.Office.Server.dll)
Syntaxe
'Déclaration
Public NotInheritable Class ServerContext
'Utilisation
Dim instance As ServerContext
public sealed class ServerContext
Exemples
//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());
}
}
}
}
Cohérence de thread
Tous les membres statique (Partagé dans Visual Basic)s publics de ce type sont thread-safe. Cela n’est pas garanti pour les membres d’instance.