CredUIParseUserNameA function (wincred.h)
The CredUIParseUserName function extracts the domain and user account name from a fully qualified user name.
CREDUIAPI DWORD CredUIParseUserNameA( PCSTR userName, CHAR *user, ULONG userBufferSize, CHAR *domain, ULONG domainBufferSize );
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.
Pointer to a null-terminated string that receives the user account name.
Maximum number of characters to write to the pszUser string including the terminating null character.
Pointer to a null-terminated string that receives the domain name. If pszUserName specifies a certificate, pszDomain will be NULL.
Maximum number of characters to write to the pszDomain string including the terminating null character.
This function returns the following:
The user name is valid.
The user name is not valid.
One of the buffers is too small.
- ulUserMaxChars or ulDomainMaxChars is zero.
- pszUserName, pszUser, or pszDomain is NULL.
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:
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.
<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 ().
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.
The wincred.h header defines CredUIParseUserName as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
|Minimum supported client||Windows XP [desktop apps only]|
|Minimum supported server||Windows Server 2003 [desktop apps only]|