UserProfileManager UserProfileManager UserProfileManager Class

Definition

Represents a collection of UserProfile objects that are used to access user profile data. To access a specific user profile, call the UserProfileManager class to create a UserProfile object and then retrieve the corresponding data from the user profile database.

public ref class UserProfileManager : Microsoft::Office::Server::UserProfiles::ProfileManagerBase
public class UserProfileManager : Microsoft.Office.Server.UserProfiles.ProfileManagerBase
Public Class UserProfileManager
Inherits ProfileManagerBase
Inheritance
UserProfileManagerUserProfileManagerUserProfileManager

Examples

<p>The following code example uses the <xref data-throw-if-not-resolved="true" uid="Microsoft.Office.Server.UserProfiles.UserProfileManager"></xref> class.</p>
<p>[Visual Basic]</p>
<pre><code>      Public Sub UserProfileSample()
     'get current service context
     Dim strUrl As String = "http://SampleName"
     Dim site as SPSite = new SPSite(strUrl)
     Dim serviceContext As SPServiceContext = SPServiceContext.GetContext(site)

     'initialize user profile config manager object
     Dim upm As New UserProfileManager(serviceContext)
     'create user sample
     Dim sAccount As String = "mydomain\myalias"
     If Not upm.UserExists(sAccount) Then
        upm.CreateUserProfile(sAccount)
     End If
     'to set prop values on user profile
     Dim u As UserProfile = upm.GetUserProfile(sAccount)
     Dim sPropName As String = "PreferredName"
     u(sPropName) = sAccount
     u.Commit()

     'remove user profile sample
     upm.RemoveUserProfile(sAccount)
  End Sub 'UserProfileSample


  Public Sub CreatePersonalSiteSample()
     'get current service context
     Dim serviceContext As SPServiceContext = SPServiceContext.Current

     'initialize user profile config manager object
     Dim upm As New UserProfileManager(serviceContext)
     Dim sAccount As String = "mydomain\myalias"
     Dim u As UserProfile = upm.GetUserProfile(sAccount)
     u.CreatePersonalSite()
     Dim mysite As SPSite = u.PersonalSite
     Dim myurl As String = u.PersonalUrl
  End Sub 'CreatePersonalSiteSample</code></pre>
<p>[C#]</p>
<pre><code>public void UserProfileSample()

{ //get current service context strUrl = "http://SampleName"; SPSite site = new SPSite(strUrl); SPServiceContext serviceContext = SPServiceContext.GetContext(site);

//initialize user profile config manager object UserProfileManager upm = new UserProfileManager(serviceContext); //create user sample string sAccount = "mydomain\myalias"; if (!upm.UserExists(sAccount)) upm.CreateUserProfile(sAccount);

//to set prop values on user profile UserProfile u = upm.GetUserProfile(sAccount); string sPropName = "PreferredName"; u[sPropName] = sAccount; u.Commit();

//remove user profile sample upm.RemoveUserProfile(sAccount); }

public void CreatePersonalSiteSample() { //get current service context SPServiceContext serviceContext = SPServiceContext.Current;

//initialize user profile config manager object UserProfileManager upm = new UserProfileManager(serviceContext); string sAccount = "mydomain\myalias"; UserProfile u = upm.GetUserProfile(sAccount); u.CreatePersonalSite(); SPSite mysite = u.PersonalSite; string myurl = u.PersonalUrl; }

Remarks

You must create the UserProfileManager object before you access a UserProfile object. You can then retrieve the user profiles that the user can access. Full access to everyone's user profile requires "Manage User Profiles" rights. Full access to your own profile requires "Use Personal Features" rights. Everyone has read access to all profiles.

You must use the UserProfileConfigManager class object instead of the UserProfileManager object to manage metadata. The metadata access that the UserProfileManager object provides is meant to be read-only. Only the users who are listed in the Permissions ACL of the User Profile Service Application can create an instance of a UserProfileManager object.

Constructors

UserProfileManager() UserProfileManager() UserProfileManager()

Initializes a new instance of the UserProfileManagerclass.

UserProfileManager(Boolean) UserProfileManager(Boolean) UserProfileManager(Boolean)

Initializes a new instance of the UserProfileManager class.

UserProfileManager(ServerContext) UserProfileManager(ServerContext) UserProfileManager(ServerContext)

Initializes a new instance of the UserProfileManager class for the specified server context.

UserProfileManager(ServerContext, Boolean) UserProfileManager(ServerContext, Boolean) UserProfileManager(ServerContext, Boolean)

Initializes a new instance of the UserProfileManager class for the specified server context.

UserProfileManager(ServerContext, Boolean, Boolean) UserProfileManager(ServerContext, Boolean, Boolean) UserProfileManager(ServerContext, Boolean, Boolean)

Initializes a new instance of the UserProfileManager class for the specified server context.

UserProfileManager(SPServiceContext) UserProfileManager(SPServiceContext) UserProfileManager(SPServiceContext)

Initializes a new instance of the UserProfileManager class for the specified service context.

UserProfileManager(SPServiceContext, Boolean) UserProfileManager(SPServiceContext, Boolean) UserProfileManager(SPServiceContext, Boolean)

Initializes a new instance of the UserProfileManager class for the specified service context.

UserProfileManager(SPServiceContext, Boolean, Boolean) UserProfileManager(SPServiceContext, Boolean, Boolean) UserProfileManager(SPServiceContext, Boolean, Boolean)

Initializes a new instance of the UserProfileManager class for the specified service context.

Properties

AccountNameFormat AccountNameFormat AccountNameFormat

Gets the account name format.

(Inherited from ProfileManagerBase)
Count Count Count

Gets the total number of user profiles contained in the database.

CurrentChangeToken CurrentChangeToken CurrentChangeToken

Gets the current change token for this profile type.

(Inherited from ProfileManagerBase)
DefaultProfileSubtypeProperties DefaultProfileSubtypeProperties DefaultProfileSubtypeProperties

Gets the default ProfileSubtypePropertyManager.

(Inherited from ProfileManagerBase)
GlobalPersonalSitesList GlobalPersonalSitesList GlobalPersonalSitesList

Gets a list of global personal site locations

IsClaimProvider IsClaimProvider IsClaimProvider

Gets or sets a value determining whether to force explicit use or explicit non-use of user profile data for the purpose of providing claims.

IsPersonalSiteMultipleLanguage IsPersonalSiteMultipleLanguage IsPersonalSiteMultipleLanguage

Gets or sets a value indicating whether personal sites can be created in multiple languages.

MySiteEmailSenderName MySiteEmailSenderName MySiteEmailSenderName

Gets or sets the name of the e-mail sender name for MySites in the current context.

MySiteHostCompatibilityLevel MySiteHostCompatibilityLevel MySiteHostCompatibilityLevel
MySiteHostMicrofeedEnabled MySiteHostMicrofeedEnabled MySiteHostMicrofeedEnabled
MySiteHostUrl MySiteHostUrl MySiteHostUrl

Gets or sets the URL to the site which hosts MySites for the current context.

PersonalizationLinksList PersonalizationLinksList PersonalizationLinksList

Gets a list of personalization sites for the current context.

PersonalSiteFormat PersonalSiteFormat PersonalSiteFormat

Gets or sets the naming format for personal sites (for example, domain_username or username).

PersonalSiteInclusion PersonalSiteInclusion PersonalSiteInclusion

Gets the inclusion under which personal sites are created.

PersonalSiteReaders PersonalSiteReaders PersonalSiteReaders

Gets or sets a list of users who will be added as readers on new personal sites.

Properties Properties Properties

Gets the collection of defined profile properties, not including sections.

(Inherited from ProfileManagerBase)
PropertiesWithSection PropertiesWithSection PropertiesWithSection

Gets the collection of defined profile properties, including sections.

(Inherited from ProfileManagerBase)
UserProfileChangeJobSchedule UserProfileChangeJobSchedule UserProfileChangeJobSchedule

Methods

AddLeader(String) AddLeader(String) AddLeader(String)

Adds a new leader to the user profile database.

CreateUserProfile() CreateUserProfile() CreateUserProfile()

Creates a user profile.

CreateUserProfile(String) CreateUserProfile(String) CreateUserProfile(String)

Creates a user profile with the specified account name.

CreateUserProfile(String, String) CreateUserProfile(String, String) CreateUserProfile(String, String)

Creates a user profile with the specified account name and preferred name.

GetChanges() GetChanges() GetChanges()

Returns all changes made to a user’s profile.

GetChanges(ProfileBaseChangeQuery) GetChanges(ProfileBaseChangeQuery) GetChanges(ProfileBaseChangeQuery)

Returns changes made to a user’s profile that are defined by the specified change query.

GetChanges(UserProfileChangeToken) GetChanges(UserProfileChangeToken) GetChanges(UserProfileChangeToken)

Returns changes made to a user’s profile from a specific location in the change logs that is represented by the specified change token.

GetEnumerator() GetEnumerator() GetEnumerator()

Returns an IEnumerator that can be used to iterate through all profiles.

(Inherited from ProfileManagerBase)
GetEnumerator(Int64, Int32) GetEnumerator(Int64, Int32) GetEnumerator(Int64, Int32)

Returns an IEnumerator that can be used to iterate through a specified number of profiles.

(Inherited from ProfileManagerBase)
GetLeaders() GetLeaders() GetLeaders()

Gets the leaders in the user profile database.

GetMemberGroups() GetMemberGroups() GetMemberGroups()

Gets the MemberGroupManager for the current context.

GetPrivacyPolicy() GetPrivacyPolicy() GetPrivacyPolicy()

Gets the privacy policy for the current context.

GetProfile(Int64) GetProfile(Int64) GetProfile(Int64)

Gets the user profile with the specified record identifier.

GetStringSinglePropertyValueForUser(SPServiceContext, String, String) GetStringSinglePropertyValueForUser(SPServiceContext, String, String) GetStringSinglePropertyValueForUser(SPServiceContext, String, String)

Retrieves the single-valued property for the UserProfile whose name matches the propertyName parameter of the UserProfile identified by the accountName parameter.

GetUserProfile(Boolean) GetUserProfile(Boolean) GetUserProfile(Boolean)

Gets the UserProfile object of the current user or creates one if the UserProfile object does not already exist.

GetUserProfile(Byte[]) GetUserProfile(Byte[]) GetUserProfile(Byte[])

Gets the UserProfile object for the specified SID in byte[] format.

GetUserProfile(Guid) GetUserProfile(Guid) GetUserProfile(Guid)

Gets the UserProfile object for the specified GUID.

GetUserProfile(Int64) GetUserProfile(Int64) GetUserProfile(Int64)

Gets the UserProfile object for the specified record identifier.

GetUserProfile(Int64, Boolean) GetUserProfile(Int64, Boolean) GetUserProfile(Int64, Boolean)
GetUserProfile(String) GetUserProfile(String) GetUserProfile(String)

Gets the UserProfile object for the specified account name.

GetUserProfile(String, Boolean) GetUserProfile(String, Boolean) GetUserProfile(String, Boolean)

Retrieves the requested user's profile.

IsAvailable(SPServiceContext) IsAvailable(SPServiceContext) IsAvailable(SPServiceContext)

Gets a value indicating whether there is a working connection to a User Profile Application in the specified service context.

RemoveLeader(String) RemoveLeader(String) RemoveLeader(String)

Removes the specified leader from the user profile database.

RemoveProfile(ProfileBase) RemoveProfile(ProfileBase) RemoveProfile(ProfileBase)

Removes the specified user profile from the database.

RemoveUserProfile(Guid) RemoveUserProfile(Guid) RemoveUserProfile(Guid)

Removes the user profile, quick links, and alert data from the user profile database for the specified GUID.

RemoveUserProfile(String) RemoveUserProfile(String) RemoveUserProfile(String)

Removes the user profile, quick links, and alert data from the user profile database for the specified account name.

ResolveProfile(String) ResolveProfile(String) ResolveProfile(String)

Returns an array of ProfileBase objects that match the specified search pattern.

(Inherited from ProfileManagerBase)
Search(OrganizationProfile, String) Search(OrganizationProfile, String) Search(OrganizationProfile, String)

Retrieves an array of users and organizations (as ProfileBase objects) under the specified OrganizationProfile object whose searchable properties match a specified search pattern.

(Inherited from ProfileManagerBase)
Search(OrganizationProfile, String[]) Search(OrganizationProfile, String[]) Search(OrganizationProfile, String[])

Retrieves an array of users and organizations (as ProfileBase objects) under the specified OrganizationProfile object whose searchable properties match the specified search patterns.

(Inherited from ProfileManagerBase)
Search(String) Search(String) Search(String)

Retrieves an array of ProfileBase objects of a particular profile type whose searchable properties match the specified search pattern.

(Inherited from ProfileManagerBase)
Search(String[]) Search(String[]) Search(String[])

Retrieves an array of ProfileBase objects of a particular profile type whose searchable properties match the specified search patterns.

(Inherited from ProfileManagerBase)
Search(String[], Int32, Nullable<Boolean>) Search(String[], Int32, Nullable<Boolean>) Search(String[], Int32, Nullable<Boolean>)

Return profiles for specific subtypes, 0 means all subtypes.

(Inherited from ProfileManagerBase)
UserExists(String) UserExists(String) UserExists(String)

Returns a value indicating whether the user for a specified account name has a user profile.

Extension Methods

ToJson(Object) ToJson(Object) ToJson(Object)

Applies to