ServerContext Class
Collapse the table of content
Expand the table of content

ServerContext Class

Provides run-time methods for shared services in Microsoft Office SharePoint Server 2007.


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

[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class ServerContext

//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 
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)
                using (SPSite site = new SPSite("http://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";
            catch (UserNotFoundException exception)

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

© 2016 Microsoft