LookupAccountName函数接受系统和帐户的名称作为输入检索帐户的安全标识符(SID)和找到该帐户的域的名称

LookupAccountName函数接受系统和帐户的名称作为输入。它检索帐户的安全标识符(SID)和找到该帐户的域的名称。


LookupAccountName
The LookupAccountName function accepts the name of a system and an account as input. It retrieves a security identifier (SID) for the account and the name of the domain on which the account was found.


The LsaLookupNames function can also retrieve computer accounts. 
LsaLookupNames函数还可以检索计算机帐户。 


Windows NT:  The LsaLookupNames function does not retrieve computer accounts.
Windows NT:LsaLookupNames函数不检索计算机帐户。


BOOL LookupAccountName(
  LPCTSTR lpSystemName,
  LPCTSTR lpAccountName,
  PSID Sid,
  LPDWORD cbSid,
  LPTSTR ReferencedDomainName,
  LPDWORD cchReferencedDomainName,
  PSID_NAME_USE peUse
);


Parameters
lpSystemName 
[in] Pointer to a null-terminated character string that specifies the name of the system. This string can be the name of a remote computer. If this string 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. 
指向指定系统名称的以null结尾的字符串的指针。该字符串可以是远程计算机的名称。如果此字符串为NULL,则帐户名称翻译从本地系统开始。如果本地系统无法解析名称,则此功能将尝试使用本地系统信任的域控制器来解析该名称。通常,仅当帐户在不受信任的域中并且该域中的计算机的名称已知时才指定lpSystemName的值。


lpAccountName 
[in] Pointer to a null-terminated string that specifies the account name.
Use a fully qualified string in the domain_name\user_name format to ensure that LookupAccountName finds the account in the desired domain.
指向指定帐户名称的以空字符结尾的字符串的指针。
使用domain_name \ user_name格式的完全限定字符串,以确保LookupAccountName在所需的域中找到该帐户。


Sid 
[out] Pointer to a buffer that receives the SID structure that corresponds to the account name pointed to by the lpAccountName parameter. If this parameter is NULL, cbSid must be zero. 
指向接收与lpAccountName参数指向的帐户名对应的SID结构的缓冲区的指针。如果此参数为NULL,则cbSid必须为零。
cbSid 
[in, out] Pointer to a variable. On input, this value specifies the size, in bytes, of the Sid buffer. If the function fails because the buffer is too small or if cbSid is zero, this variable receives the required buffer size. 
ReferencedDomainName 
指向变量的指针。在输入时,此值指定Sid缓冲区的大小(以字节为单位)。如果该函数失败,因为缓冲区太小或cbSid为零,该变量将接收所需的缓冲区大小。
[out] Pointer to a buffer that receives the name of the domain where the account name is found. For computers that are not joined to a domain, this buffer receives the computer name. If this parameter is NULL, the function returns the required buffer size. 
指向缓冲区的指针,该缓冲区接收到找到该帐户名称的域名。对于未加入域的计算机,此缓冲区将接收计算机名称。如果此参数为NULL,则该函数返回所需的缓冲区大小。
cchReferencedDomainName 
[in, out] Pointer to a variable. On input, this value specifies the size, in TCHARs, of the ReferencedDomainName buffer. If the function fails because the buffer is too small, this variable receives the required buffer size, including the terminating null character. If the ReferencedDomainName parameter is NULL, this parameter must be zero. 
指向变量的指针。在输入上,该值指定在TCHAR中ReferencedDomainName缓冲区的大小。如果该函数由于缓冲区太小而失败,则该变量将接收所需的缓冲区大小,包括终止空字符。如果ReferencedDomainName参数为NULL,则此参数必须为零。
peUse 
[out] Pointer to a SID_NAME_USE enumerated type that indicates the type of the account when the function returns. 
指向SID_NAME_USE枚举类型的指针,指示函数返回时的帐户类型。 


Return Values
If the function succeeds, the function returns nonzero.
If the function fails, it returns zero. For extended error information, call GetLastError.
如果函数成功,函数将返回非零值。
如果函数失败,则返回零。对于扩展错误信息,调用GetLastError。


Remarks
The LookupAccountName function attempts to find a SID for the specified name by first checking a list of well-known SIDs. If the name does not correspond to a well-known SID, the function checks built-in and administratively defined local accounts. Next, the function checks the primary domain. If the name is not found there, trusted domains are checked.
LookupAccountName函数尝试通过首先检查众所周知的SID列表来查找指定名称的SID。如果名称与众所周知的SID不对应,则该函数将检查内置和管理定义的本地帐户。接下来,该函数检查主域。如果没有找到该名称,那么将检查受信任的域。


Use fully qualified account names (for example, domain_name\user_name) instead of isolated names (for example, user_name). Fully qualified names are unambiguous and provide better performance when the lookup is performed. This function also supports fully qualified DNS names (for example, example.example.com\user_name) and user principal names (UPN) (for example, someone@example.com).


使用完全限定的帐户名称(例如,domain_name \ user_name),而不是隔离名称(例如user_name)。完全限定名称是明确的,并且在执行查找时提供更好的性能。此功能还支持完全限定的DNS名称(例如example.example.com \ user_name)和用户主体名称(UPN)(例如,someone@example.com)。




Windows NT:  DNS and UPN names are not supported by this function.
Windows NT:此功能不支持DNS和UPN名称。


In addition to looking up local accounts, local domain accounts, and explicitly trusted domain accounts, LookupAccountName can look up the name for any account in any domain in the forest.
LookupAccountName除了查找本地帐户,本地域帐户和明确信任的域帐户外,还可以查找林中任何域中的任何帐户的名称。


Windows NT:  Forest lookup is not supported.
Windows NT:不支持林查找。




Requirements
Client Requires Windows XP, Windows 2000 Professional, or Windows NT Workstation 3.1 and later. 
Server Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 3.1 and later. 


Header Declared in Winbase.h; include Windows.h.
头文件在Winbase.h中声明; 包括Windows.h。 
Library Link to Advapi32.lib.
 Library链接到Advapi32.lib。
 
DLL Requires Advapi32.dll.  
Unicode Implemented as LookupAccountNameW (Unicode) and LookupAccountNameA (ANSI).
 DLL需要Advapi32.dll。  
Unicode实现为LookupAccountNameW(Unicode)和LookupAccountNameA(ANSI)。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值