User​Information User​Information User​Information Class

Definition

Represents information about the user, such as name and account picture.

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks.

public static class UserInformationpublic static class UserInformationPublic Static Class UserInformation
Attributes
Windows 10 requirements
Device family
Windows Desktop Extension SDK (introduced v10.0.10240.0) Windows Mobile Extension SDK (introduced v10.0.10240.0)
API contract
Windows.System.UserProfile.UserProfileContract (introduced v1)

Remarks

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead.

Windows 10 Apps compiled for Windows 8 that use the UserInformation class no longer return user information when running on Windows 10. This is because in Windows 10, apps do not have access to user information without explicit user consent, unlike in Windows 8 where this permission is granted by default.

If you have a Windows 8 app that uses the UserInformation class, you should migrate your app to the Universal Windows Platform (UWP) and access the User class instead. Universal Windows Platform (UWP) app that access user information are now expected to declare a new capability, uap:userAccountInformation, and call new APIs, Windows.System.User.FindAllAsync and User.GetPropertiesAsync, to get the data.

When users install the app, they are prompted to allow access to their user information. If the user allows the app to access the information, the app appears listed in the Privacy page of the Windows 10 Settings UI (Settings > Privacy > Account info). This allows Windows 10 users to enable access to user information on a per-app basis.

You can also enable access to user information without additional code modification by deploying a group policy change, which is particularly useful for business and enterprise customers. To allow access to user information on Windows 10, enable the following group policy setting and set it to "Always On": Computer Configuration > Administrative Templates > System > User Profiles > User management of sharing user name, account picture, and domain information with apps (not desktop apps). For more info, download Group Policy Settings Reference for Windows and Windows Server.

Windows 8 To be launched in account picture mode and to set the user's picture without additional prompting, an app must register as an account picture provider by including the following in the Extensions section of the app manifest.

Examples

function getUserInfo() {
    image = Windows.System.UserProfile.UserInformation.getAccountPicture(Windows.System.UserProfile.AccountPictureKind.smallImage);
    imageURL = URL.createObjectURL(image, false);
}    

Properties

AccountPictureChangeEnabled AccountPictureChangeEnabled AccountPictureChangeEnabled

Determines if the user's account picture can be changed.

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

public static bool AccountPictureChangeEnabled { get; }public static bool AccountPictureChangeEnabled { get; }Public Static ReadOnly Property AccountPictureChangeEnabled As bool
Value
bool bool bool

True if the user's account picture can be changed; false otherwise.

Attributes

Remarks

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

NameAccessAllowed NameAccessAllowed NameAccessAllowed

Allows you to see if your app is allowed to access the user's information.

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

public static bool NameAccessAllowed { get; }public static bool NameAccessAllowed { get; }Public Static ReadOnly Property NameAccessAllowed As bool
Value
bool bool bool

True if your app is allowed access to the AccountPictureChanged event, and is allowed to retrieve user information by using the GetAccountPicture, GetDisplayNameAsync, GetDomainNameAsync, GetFirstNameAsync, GetLastNameAsync, and GetSessionInitiationProtocolUriAsync methods. Otherwise, this property is false.

Attributes

Remarks

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

If this property is false, the GetDisplayNameAsync, GetDomainNameAsync, GetFirstNameAsync, and GetLastNameAsync methods return an empty string, while the GetAccountPicture and GetSessionInitiationProtocolUriAsync methods return a null value.

Methods

GetAccountPicture(AccountPictureKind) GetAccountPicture(AccountPictureKind) GetAccountPicture(AccountPictureKind)

Gets the account picture for the user.

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

public static IStorageFile GetAccountPicture(AccountPictureKind kind)public static IStorageFile GetAccountPicture(AccountPictureKind kind)Public Static Function GetAccountPicture(kind As AccountPictureKind) As IStorageFile
Parameters
kind
AccountPictureKind AccountPictureKind AccountPictureKind

An enumeration that you can use to determine what type of image you want (small, large, and so on).

Returns

An object that contains the image.

Attributes

Remarks

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

Access to the account picture can be blocked by privacy settings (for example, if the UserInformation::NameAccessAllowed property is false). If access is blocked, this method returns a null value.

This method does not throw an exception.

GetDisplayNameAsync() GetDisplayNameAsync() GetDisplayNameAsync()

Gets the display name for the user account.

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

public static IAsyncOperation<string> GetDisplayNameAsync()public static IAsyncOperation<string> GetDisplayNameAsync()Public Static Function GetDisplayNameAsync() As IAsyncOperation( Of string )
Returns

The display name for the user account.

Attributes

Remarks

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

Access to the display name can be blocked by privacy settings (for example, if the UserInformation::NameAccessAllowed property is false). If access is blocked, this method returns an empty string.

This method does not throw an exception.

GetDomainNameAsync() GetDomainNameAsync() GetDomainNameAsync()

Gets the domain name for the user.

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

public static IAsyncOperation<string> GetDomainNameAsync()public static IAsyncOperation<string> GetDomainNameAsync()Public Static Function GetDomainNameAsync() As IAsyncOperation( Of string )
Returns

A string that represents the domain name for the user.

Attributes

Remarks

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

Access to the domain name can be blocked by privacy settings (for example, if the UserInformation::NameAccessAllowed property is false). If access is blocked, this method returns an empty string.

This method does not throw an exception.

GetFirstNameAsync() GetFirstNameAsync() GetFirstNameAsync()

Gets the user's first name.

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

public static IAsyncOperation<string> GetFirstNameAsync()public static IAsyncOperation<string> GetFirstNameAsync()Public Static Function GetFirstNameAsync() As IAsyncOperation( Of string )
Returns

The user's first name.

Attributes

Remarks

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

Access to the user's first name can be blocked by privacy settings (for example, if the UserInformation::NameAccessAllowed property is false). If access is blocked, this method returns an empty string.

This method does not throw an exception.

GetLastNameAsync() GetLastNameAsync() GetLastNameAsync()

Gets the user's last name.

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

public static IAsyncOperation<string> GetLastNameAsync()public static IAsyncOperation<string> GetLastNameAsync()Public Static Function GetLastNameAsync() As IAsyncOperation( Of string )
Returns

The user's last name.

Attributes

Remarks

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

Access to the user's last name can be blocked by privacy settings (for example, if the UserInformation::NameAccessAllowed property is false). If access is blocked, this method returns an empty string.

This method does not throw an exception.

GetPrincipalNameAsync() GetPrincipalNameAsync() GetPrincipalNameAsync()

Gets the principal name for the user. This name is the User Principal Name (typically the user's address, although this is not always true.)

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

public static IAsyncOperation<string> GetPrincipalNameAsync()public static IAsyncOperation<string> GetPrincipalNameAsync()Public Static Function GetPrincipalNameAsync() As IAsyncOperation( Of string )
Returns

The user's principal name.

Attributes

Remarks

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

Only domain users have a principal name. Access to the principal name can be blocked by privacy settings (for example, if the UserInformation::NameAccessAllowed property is false). If access is blocked, this method returns an empty string.

This method requires the enterpriseAuthentication capability.

This method does not throw an exception.

GetSessionInitiationProtocolUriAsync() GetSessionInitiationProtocolUriAsync() GetSessionInitiationProtocolUriAsync()

Gets the Uniform Resource Identifier (URI) of the session initiation protocol for the user.

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

public static IAsyncOperation<Uri> GetSessionInitiationProtocolUriAsync()public static IAsyncOperation<Uri> GetSessionInitiationProtocolUriAsync()Public Static Function GetSessionInitiationProtocolUriAsync() As IAsyncOperation( Of Uri )
Returns

The Uniform Resource Identifier (URI) of the session initiation protocol.

Attributes

Remarks

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

Access to the Uniform Resource Identifier (URI) of the session initiation protocol for the user can be blocked by privacy settings (for example, if the UserInformation::NameAccessAllowed property is false). If access is blocked, this method returns a null value.

This method does not throw an exception.

SetAccountPictureAsync(IStorageFile) SetAccountPictureAsync(IStorageFile) SetAccountPictureAsync(IStorageFile)

Sets the picture for the user's account using an IStorageFile object.

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

public static IAsyncOperation<SetAccountPictureResult> SetAccountPictureAsync(IStorageFile image)public static IAsyncOperation<SetAccountPictureResult> SetAccountPictureAsync(IStorageFile image)Public Static Function SetAccountPictureAsync(image As IStorageFile) As IAsyncOperation( Of SetAccountPictureResult )
Parameters
image
IStorageFile IStorageFile IStorageFile

A file that contains the image.

Returns

A value that indicates the success or failure of the operation.

Attributes

Remarks

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

SetAccountPictureFromStreamAsync(IRandomAccessStream) SetAccountPictureFromStreamAsync(IRandomAccessStream) SetAccountPictureFromStreamAsync(IRandomAccessStream)

Sets the picture for the user's account using an IRandomAccessStream object.

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

public static IAsyncOperation<SetAccountPictureResult> SetAccountPictureFromStreamAsync(IRandomAccessStream image)public static IAsyncOperation<SetAccountPictureResult> SetAccountPictureFromStreamAsync(IRandomAccessStream image)Public Static Function SetAccountPictureFromStreamAsync(image As IRandomAccessStream) As IAsyncOperation( Of SetAccountPictureResult )
Parameters
Returns

A value that indicates the success or failure of the operation.

Attributes

Remarks

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

SetAccountPicturesAsync(IStorageFile, IStorageFile, IStorageFile) SetAccountPicturesAsync(IStorageFile, IStorageFile, IStorageFile) SetAccountPicturesAsync(IStorageFile, IStorageFile, IStorageFile)

Sets the pictures for the user's account using an IStorageFile object. Supports adding a small image, large image, and video.

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

public static IAsyncOperation<SetAccountPictureResult> SetAccountPicturesAsync(IStorageFile smallImage, IStorageFile largeImage, IStorageFile video)public static IAsyncOperation<SetAccountPictureResult> SetAccountPicturesAsync(IStorageFile smallImage, IStorageFile largeImage, IStorageFile video)Public Static Function SetAccountPicturesAsync(smallImage As IStorageFile, largeImage As IStorageFile, video As IStorageFile) As IAsyncOperation( Of SetAccountPictureResult )
Parameters
smallImage
IStorageFile IStorageFile IStorageFile

A small version of the image.

largeImage
IStorageFile IStorageFile IStorageFile

A large version of the image.

Returns

A value that indicates the success or failure of the operation.

Attributes

Remarks

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

SetAccountPicturesFromStreamsAsync(IRandomAccessStream, IRandomAccessStream, IRandomAccessStream) SetAccountPicturesFromStreamsAsync(IRandomAccessStream, IRandomAccessStream, IRandomAccessStream) SetAccountPicturesFromStreamsAsync(IRandomAccessStream, IRandomAccessStream, IRandomAccessStream)

Sets the pictures for the user's account using an IRandomAccessStream object. Supports adding a small image, large image, and video.

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

public static IAsyncOperation<SetAccountPictureResult> SetAccountPicturesFromStreamsAsync(IRandomAccessStream smallImage, IRandomAccessStream largeImage, IRandomAccessStream video)public static IAsyncOperation<SetAccountPictureResult> SetAccountPicturesFromStreamsAsync(IRandomAccessStream smallImage, IRandomAccessStream largeImage, IRandomAccessStream video)Public Static Function SetAccountPicturesFromStreamsAsync(smallImage As IRandomAccessStream, largeImage As IRandomAccessStream, video As IRandomAccessStream) As IAsyncOperation( Of SetAccountPictureResult )
Parameters
smallImage
IRandomAccessStream IRandomAccessStream IRandomAccessStream

A small version of the image.

largeImage
IRandomAccessStream IRandomAccessStream IRandomAccessStream

A large version of the image.

Returns

A value that indicates the success or failure of the operation.

Attributes

Remarks

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

Events

AccountPictureChanged AccountPictureChanged AccountPictureChanged

Occurs when the user's image or name changes.

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

public static event EventHandler AccountPictureChangedpublic static event EventHandler AccountPictureChangedPublic Static Event AccountPictureChanged
Attributes

Remarks

Important

The UserInformation class is not supported on Windows 10 or later. Use the User class instead. See Remarks in the UserInformation class documentation.

Use this event to monitor changes to the user's account picture.

Access to this event can be blocked by privacy settings. If access is blocked, the AccountPictureChangeEnabled property will be false.