Dela via


UserInformation.GetPrincipalNameAsync Method

Definition

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<Platform::String ^> ^ GetPrincipalNameAsync();
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<winrt::hstring> GetPrincipalNameAsync();
/// [Windows.Foundation.Metadata.RemoteAsync]
/// [Windows.Foundation.Metadata.Deprecated("Use User instead of UserInformation. For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 131072, "Windows.System.UserProfile.UserProfileContract")]
 static IAsyncOperation<winrt::hstring> GetPrincipalNameAsync();
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<string> GetPrincipalNameAsync();
[Windows.Foundation.Metadata.RemoteAsync]
[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 IAsyncOperation<string> GetPrincipalNameAsync();
function getPrincipalNameAsync()
Public Shared Function GetPrincipalNameAsync () As IAsyncOperation(Of String)

Returns

IAsyncOperation<String>

IAsyncOperation<Platform::String>

IAsyncOperation<winrt::hstring>

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.

Applies to

See also