LookupAccountSidLocalW function (winbase.h)

Retrieves the name of the account for the specified SID on the local machine.

Syntax

BOOL LookupAccountSidLocalW(
  PSID          Sid,
  LPWSTR        Name,
  LPDWORD       cchName,
  LPWSTR        ReferencedDomainName,
  LPDWORD       cchReferencedDomainName,
  PSID_NAME_USE peUse
);

Parameters

Sid

A pointer to the SID to look up.

Name

A pointer to a buffer that receives a null-terminated string that contains the account name that corresponds to the lpSid parameter.

cchName

On input, specifies the size, in TCHARs, of the lpName buffer. If the function fails because the buffer is too small or if cchName is zero, cchName receives the required buffer size, including the terminating null character.

ReferencedDomainName

A pointer to a buffer that receives a null-terminated string that contains the name of the domain where the account name was found.

On a server, the domain name returned for most accounts in the security database of the local computer is the name of the domain for which the server is a domain controller.

On a workstation, the domain name returned for most accounts in the security database of the local computer is the name of the computer as of the last start of the system (backslashes are excluded). If the name of the computer changes, the old name continues to be returned as the domain name until the system is restarted.

Some accounts are predefined by the system. The domain name returned for these accounts is BUILTIN.

cchReferencedDomainName

On input, specifies the size, in TCHARs, of the lpReferencedDomainName buffer. If the function fails because the buffer is too small or if cchReferencedDomainName is zero, cchReferencedDomainName receives the required buffer size, including the terminating null character.

peUse

A pointer to a variable that receives a SID_NAME_USE value that indicates the type of the account.

Return value

If the function succeeds, the function returns nonzero.

If the function fails, it returns zero. To get extended error information, call GetLastError.

Remarks

This function is similar to LookupAccountSid, but restricts the search to the local machine.

Note

The winbase.h header defines LookupAccountSidLocal 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.

Requirements

   
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header winbase.h (include Windows.h)
Library Advapi32.lib
DLL Advapi32.dll

See also

Access Control Overview

Basic Access Control Functions

EqualPrefixSid

LookupAccountName

SID

SID_NAME_USE