|
SecurityHelperLookupAccountSid(String, Byte, StringBuilder, Int32, StringBuilder, Int32, Int32) Method |
The LookupAccountSid function accepts a security identifier (SID) as input. It retrieves
the name of the account for this SID and the name of the first domain on which this SID is
found.
LookupAccountSid function Namespace: Xcalibur.NativeMethods.V2.SecurityAssembly: Xcalibur.NativeMethods.V2 (in Xcalibur.NativeMethods.V2.dll) Version: 1.0.1.0
Syntax [DllImportAttribute("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static bool LookupAccountSid(
string systemName,
byte[] sid,
StringBuilder userName,
ref int userNameSize,
StringBuilder domainName,
ref int domainNameSize,
out int use
)
<DllImportAttribute("advapi32.dll", CharSet := CharSet.Unicode, SetLastError := true>]
Public Shared Function LookupAccountSid (
systemName As String,
sid As Byte(),
userName As StringBuilder,
ByRef userNameSize As Integer,
domainName As StringBuilder,
ByRef domainNameSize As Integer,
<OutAttribute> ByRef use As Integer
) As Boolean
public:
[DllImportAttribute(L"advapi32.dll", CharSet = CharSet::Unicode, SetLastError = true)]
static bool LookupAccountSid(
String^ systemName,
array<unsigned char>^ sid,
StringBuilder^ userName,
int% userNameSize,
StringBuilder^ domainName,
int% domainNameSize,
[OutAttribute] int% use
)
[<DllImportAttribute("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)>]
static member LookupAccountSid :
systemName : string *
sid : byte[] *
userName : StringBuilder *
userNameSize : int byref *
domainName : StringBuilder *
domainNameSize : int byref *
use : int byref -> bool
Parameters
- systemName String
- A pointer to a null-terminated character string that specifies the
target computer. This string can be the name of a remote computer. If this parameter is
NULL, the account name translation begins on the local system. If the name cannot be
resolved on the local system, this function will try to resolve the name using domain
controllers trusted by the local system. Generally, specify a value for lpSystemName only
when the account is in an untrusted domain and the name of a computer in that domain is
known.
- sid Byte
- A pointer to the SID to look up.
- userName StringBuilder
- A pointer to a buffer that receives a null-terminated string that
contains the account name that corresponds to the Sid parameter.
- userNameSize Int32
- 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.
- domainName StringBuilder
- 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.
- domainNameSize Int32
- On input, specifies the size, in TCHARs, of the domainName
buffer. If the function fails because the buffer is too small or if domainNameSize is zero,
domainNameSize receives the required buffer size, including the terminating null
character.
- use Int32
- A pointer to a variable that receives a SID_NAME_USE value that indicates
the type of the account.
Return Value
BooleanIf the function succeeds, the return value is nonzero. To determine whether the
function adjusted all of the specified privileges, call
.
See Also