This topic has not yet been rated - Rate this topic

CredUIParseUserName function

Applies to: desktop apps only

The CredUIParseUserName function extracts the domain and user account name from a fully qualified user name.

Syntax

DWORD WINAPI CredUIParseUserName(
  __in   PCTSTR pszUserName,
  __out  PTSTR pszUser,
  __in   ULONG ulUserMaxChars,
  __out  PTSTR pszDomain,
  __in   ULONG ulDomainMaxChars
);

Parameters

pszUserName [in]

Pointer to a null-terminated string that contains the user name to be parsed. The name must be in UPN or down-level format, or a certificate. Typically, pszUserName is received from the CredUIPromptForCredentials or CredUICmdLinePromptForCredentials.

pszUser [out]

Pointer to a null-terminated string that receives the user account name.

ulUserMaxChars [in]

Maximum number of characters to write to the pszUser string including the terminating null character.

Note  CREDUI_MAX_USERNAME_LENGTH does NOT include the terminating null character.

pszDomain [out]

Pointer to a null-terminated string that receives the domain name. If pszUserName specifies a certificate, pszDomain will be NULL.

ulDomainMaxChars [in]

Maximum number of characters to write to the pszDomain string including the terminating null character.

Note  CREDUI_MAX_DOMAIN_TARGET_LENGTH does NOT include the terminating null character.

Return value

This function returns the following:

  • NO_ERROR

    The user name is valid.

  • ERROR_INVALID_ACCOUNT_NAME

    The user name is not valid.

  • ERROR_INSUFFICIENT_BUFFER

    One of the buffers is too small.

  • ERROR_INVALID_PARAMETER
    • ulUserMaxChars or ulDomainMaxChars is zero.
    • pszUserName, pszUser, or pszDomain is NULL.

Remarks

This function parses the user name information returned by the CredUIPromptForCredentials and CredUICmdLinePromptForCredentials functions so that the resulting credentials can be passed to functions, such as LogonUser, that require the user name and domain as separate strings.

The following formats are supported:

  • <MarshalledCredentialReference>

    Marshaled credential reference as defined by CredIsMarshaledCredential. Such a credential is returned in the User parameter. The Domain parameter is set to an empty string.

  • <DomainName>\<UserName>

    <UserName> is returned in the User parameter and the <DomainName> is returned is the Domain parameter. The name is considered to have this syntax if the UserName contains a backslash (\).

  • <UserName>@<DNSDomainName>

    The entire string is returned in the User parameter. The Domain parameter is set to an empty string. For this syntax, the last @ in the string is used because <UserName> can contain an @ but <DNSDomainName> cannot.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

WinCred.h

Library

Credui.lib

DLL

Credui.dll

Unicode and ANSI names

CredUIParseUserNameW (Unicode) and CredUIParseUserNameA (ANSI)

See also

CredIsMarshaledCredential
CredUICmdLinePromptForCredentials
CredUIPromptForCredentials
LogonUser

 

 

Send comments about this topic to Microsoft

Build date: 3/13/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ