GetUserNameExA function

Retrieves the name of the user or other security principal associated with the calling thread. You can specify the format of the returned name.

If the thread is impersonating a client, GetUserNameEx returns the name of the client.

Syntax

BOOLEAN SEC_ENTRY GetUserNameExA(
  EXTENDED_NAME_FORMAT NameFormat,
  LPSTR                lpNameBuffer,
  PULONG               nSize
);

Parameters

NameFormat

The format of the name. This parameter is a value from the EXTENDED_NAME_FORMAT enumeration type. It cannot be NameUnknown. If the user account is not in a domain, only NameSamCompatible is supported.

lpNameBuffer

A pointer to a buffer that receives the name in the specified format. The buffer must include space for the terminating null character.

nSize

TBD

Return Value

If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is zero. To get extended error information, call GetLastError. Possible values include the following.

Return code Description
ERROR_MORE_DATA
The lpNameBuffer buffer is too small. The lpnSize parameter contains the number of bytes required to receive the name.
ERROR_NO_SUCH_DOMAIN
The domain controller is not available to perform the lookup
ERROR_NONE_MAPPED
The user name is not available in the specified format.

Requirements

   
Windows version Windows 2000 Professional [desktop apps only] Windows 2000 Server [desktop apps only]
Target Platform Windows
Header secext.h (include Security.h)
Library Secur32.lib
DLL Secur32.dll

See Also

EXTENDED_NAME_FORMAT

LookupAccountName

System Information Functions