Udostępnij za pośrednictwem


UserInformation 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 ref class UserInformation abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.System.UserProfile.UserProfileContract, 65536)]
class UserInformation final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.System.UserProfile.UserProfileContract, 65536)]
/// [Windows.Foundation.Metadata.Deprecated("Use User instead of UserInformation. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 131072, "Windows.System.UserProfile.UserProfileContract")]
class UserInformation final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.System.UserProfile.UserProfileContract), 65536)]
public static class UserInformation
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.System.UserProfile.UserProfileContract), 65536)]
[Windows.Foundation.Metadata.Deprecated("Use User instead of UserInformation. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 131072, "Windows.System.UserProfile.UserProfileContract")]
public static class UserInformation
Public Class UserInformation
Inheritance
Object Platform::Object IInspectable UserInformation
Attributes

Windows requirements

Device family
Windows Desktop Extension SDK (introduced in 10.0.10240.0)
Windows Mobile Extension SDK (introduced in 10.0.10240.0)
API contract
Windows.System.UserProfile.UserProfileContract (introduced in v1.0)

Examples

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

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.

Properties

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.

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.

Methods

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

Events

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.

Applies to

See also