网站首页  词典首页

请输入您要查询的函数:

 

术语 netusergetinfo
释义 NetUserGetInfo
语法:
C++
NET_API_STATUS NetUserGetInfo(
__in LPCWSTR servername,
__in LPCWSTR username,
__in DWORD level,
__out LPBYTE *bufptr
);
NetUserGetInfo功能
该NetUserGetInfo函数检索信息服务器上的一个特定的用户帐户。
参数
服务器名 [in]
一个常量字符串,它指定的DNS或NetBIOS的远程服务器上的功能是执行名称的指针。如果该参数为NULL,则使用本地计算机。
用户名 [in]
一个常量字符串指定用户帐户的名称返回信息的指针。有关详细信息,请参阅下面的备注部分。
Level [in]
数据的信息化Level。此参数可以是下列值之一。
ValueMeaning
0Return用户帐户的名称。在bufptr参数指向USER_INFO_0结构。
1Return的详细信息的用户帐户。在bufptr参数指向USER_INFO_1结构。
2Return详细资料和用户帐户的其他属性。在bufptr参数指向USER_INFO_2结构。
3Return详细资料和用户帐户的其他属性。这个级别只适用于服务器。在bufptr参数指向USER_INFO_3结构。请注意,建议您使用USER_INFO_4代替。
4Return详细资料和用户帐户的其他属性。这个级别只适用于服务器。在bufptr参数指向USER_INFO_4结构。
Windows 2000中:此级别不支持。
10Return用户和帐户名和评论。在bufptr参数指向USER_INFO_10结构。
11Return的详细信息的用户帐户。在bufptr参数指向USER_INFO_11结构。
20Return用户的名称和标识以及各种帐户属性。在bufptr参数指向USER_INFO_20结构。请注意,在Windows XP和更高,建议您使用USER_INFO_23代替。
23Return用户的名称和标识以及各种帐户属性。在bufptr参数指向USER_INFO_23结构。
Windows 2000中:此级别不支持。
bufptr [out]
一个缓冲区,接收数据的指针。这一数据格式取决于Level的参数值。此缓冲区分配制度,必须使用NetApiBufferFree释放功能。有关更多信息,请参阅网络管理功能,缓冲器和网络管理功能缓冲区长度。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值可以是下面的错误代码之一。
返回codeDescription
ERROR_ACCESS_DENIEDThe用户没有获得所需的信息。
ERROR_BAD_NETPATHThe网络路径中指定的服务器名参数没有被发现。
ERROR_INVALID_LEVELThe价值Level参数指定无效。
NERR_InvalidComputerThe计算机名无效。
NERR_UserNotFoundThe用户名找不到。
备注
如果您是Active Directory的程序,您可以调用某些Active Directory服务接口(ADSI)的方法来达到同样的功能,您可以通过调用用户的网络管理功能。有关更多信息,请参阅IADsUser和IADsComputer。
如果您调用域控制器上运行Active Directory的这一功能,允许访问或拒绝的访问控制列表的安全对象(ACL)的基础。默认的ACL允许所有经过身份验证的用户和“前成员Windows2000兼容访问”组查看信息。如果您调用一个成员服务器或工作站,所有的身份验证的用户可以查看此功能的信息。有关匿名访问的信息,并限制在这些平台上匿名访问,看到了网络管理功能的安全要求。欲了解更多有关的ACL,ACE的,和访问令牌信息,请访问控制模型。
该用户对象的安全描述符用于执行此函数访问检查。
用户帐户名称被限制为20个字符和组名称被限制为256个字符。此外,帐户名称不能终止的期间,他们不能包含逗号或以下打印字符:“,/,\\,[,]:,|,”,“+,=,,,?, *.名称也不能包括在1-31范围内,这些非打印字符。
实例
下面的代码示例演示如何检索有关,以函数调用的NetUserGetInfo特定用户帐户信息。该范例调用NetUserGetInfo,指定各种信息的Level。如果调用成功,代码打印有关用户帐户信息。最后,该示例释放的信息缓冲区分配的内存。
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "advapi32.lib")
#pragma comment(lib, "netapi32.lib")
#include
#include
#include
#include
#include /* for ConvertSidToStringSid function */
int wmain(int argc, wchar_t * argv[])
{
DWORD dwLevel = 0;
LPUSER_INFO_0 pBuf = NULL;
LPUSER_INFO_1 pBuf1 = NULL;
LPUSER_INFO_2 pBuf2 = NULL;
LPUSER_INFO_3 pBuf3 = NULL;
LPUSER_INFO_4 pBuf4 = NULL;
LPUSER_INFO_10 pBuf10 = NULL;
LPUSER_INFO_11 pBuf11 = NULL;
LPUSER_INFO_20 pBuf20 = NULL;
LPUSER_INFO_23 pBuf23 = NULL;
NET_API_STATUS nStatus;
LPTSTR sStringSid = NULL;
int i = 0;
int j = 0;
if (argc != 3)
 {
fwprintf(stderr, L"Usage: %s \\\\\\\\ServerName UserName\\n", argv[0]);
exit(1);
}
while (i < 24)
 {
//
// Call the NetUserGetInfo function.
//
dwLevel = i;
wprintf
(L"\\nCalling NetUserGetinfo with Servername=%s Username=%s Level=%d\\n",
argv[1], argv[2], dwLevel);
nStatus = NetUserGetInfo(argv[1], argv[2], dwLevel, (LPBYTE *) & pBuf);
//
// If the call succeeds, print the user information.
//
if (nStatus == NERR_Success)
  {
if (pBuf != NULL)
 {
switch (i)
  {
case 0:
wprintf(L"\\tUser account name: %s\\n", pBuf->usri0_name);
break;
case 1:
pBuf1 = (LPUSER_INFO_1) pBuf;
wprintf(L"\\tUser account name: %s\\n", pBuf1->usri1_name);
wprintf(L"\\tPassword: %s\\n", pBuf1->usri1_password);
wprintf(L"\\tPassword age (seconds): %d\\n",
pBuf1->usri1_password_age);
wprintf(L"\\tPrivilege level: %d\\n", pBuf1->usri1_priv);
wprintf(L"\\tHome directory: %s\\n", pBuf1->usri1_home_dir);
wprintf(L"\\tUser comment: %s\\n", pBuf1->usri1_comment);
wprintf(L"\\tFlags (in hex): %x\\n", pBuf1->usri1_flags);
wprintf(L"\\tScript path: %s\\n", pBuf1->usri1_script_path);
break;
case 2:
pBuf2 = (LPUSER_INFO_2) pBuf;
wprintf(L"\\tUser account name: %s\\n", pBuf2->usri2_name);
wprintf(L"\\tPassword: %s\\n", pBuf2->usri2_password);
wprintf(L"\\tPassword age (seconds): %d\\n",
pBuf2->usri2_password_age);
wprintf(L"\\tPrivilege level: %d\\n", pBuf2->usri2_priv);
wprintf(L"\\tHome directory: %s\\n", pBuf2->usri2_home_dir);
wprintf(L"\\tComment: %s\\n", pBuf2->usri2_comment);
wprintf(L"\\tFlags (in hex): %x\\n", pBuf2->usri2_flags);
wprintf(L"\\tScript path: %s\\n", pBuf2->usri2_script_path);
wprintf(L"\\tAuth flags (in hex): %x\\n",
pBuf2->usri2_auth_flags);
wprintf(L"\\tFull name: %s\\n", pBuf2->usri2_full_name);
wprintf(L"\\tUser comment: %s\\n", pBuf2->usri2_usr_comment);
wprintf(L"\\tParameters: %s\\n", pBuf2->usri2_parms);
wprintf(L"\\tWorkstations: %s\\n", pBuf2->usri2_workstations);
wprintf
(L"\\tLast logon (seconds since January 1, 1970 GMT): %d\\n",
pBuf2->usri2_last_logon);
wprintf
(L"\\tLast logoff (seconds since January 1, 1970 GMT): %d\\n",
pBuf2->usri2_last_logoff);
wprintf
(L"\\tAccount expires (seconds since January 1, 1970 GMT): %d\\n",
pBuf2->usri2_acct_expires);
wprintf(L"\\tMax storage: %d\\n", pBuf2->usri2_max_storage);
wprintf(L"\\tUnits per week: %d\\n",
pBuf2->usri2_units_per_week);
wprintf(L"\\tLogon hours:");
for (j = 0; j < 21; j++)
   {
printf(" %x", (BYTE) pBuf2->usri2_logon_hours[j]);
}
wprintf(L"\\n");
wprintf(L"\\tBad password count: %d\\n",
pBuf2->usri2_bad_pw_count);
wprintf(L"\\tNumber of logons: %d\\n",
pBuf2->usri2_num_logons);
wprintf(L"\\tLogon server: %s\\n", pBuf2->usri2_logon_server);
wprintf(L"\\tCountry code: %d\\n", pBuf2->usri2_country_code);
wprintf(L"\\tCode page: %d\\n", pBuf2->usri2_code_page);
break;
case 4:
pBuf4 = (LPUSER_INFO_4) pBuf;
wprintf(L"\\tUser account name: %s\\n", pBuf4->usri4_name);
wprintf(L"\\tPassword: %s\\n", pBuf4->usri4_password);
wprintf(L"\\tPassword age (seconds): %d\\n",
pBuf4->usri4_password_age);
wprintf(L"\\tPrivilege level: %d\\n", pBuf4->usri4_priv);
wprintf(L"\\tHome directory: %s\\n", pBuf4->usri4_home_dir);
wprintf(L"\\tComment: %s\\n", pBuf4->usri4_comment);
wprintf(L"\\tFlags (in hex): %x\\n", pBuf4->usri4_flags);
wprintf(L"\\tScript path: %s\\n", pBuf4->usri4_script_path);
wprintf(L"\\tAuth flags (in hex): %x\\n",
pBuf4->usri4_auth_flags);
wprintf(L"\\tFull name: %s\\n", pBuf4->usri4_full_name);
wprintf(L"\\tUser comment: %s\\n", pBuf4->usri4_usr_comment);
wprintf(L"\\tParameters: %s\\n", pBuf4->usri4_parms);
wprintf(L"\\tWorkstations: %s\\n", pBuf4->usri4_workstations);
wprintf
(L"\\tLast logon (seconds since January 1, 1970 GMT): %d\\n",
pBuf4->usri4_last_logon);
wprintf
(L"\\tLast logoff (seconds since January 1, 1970 GMT): %d\\n",
pBuf4->usri4_last_logoff);
wprintf
(L"\\tAccount expires (seconds since January 1, 1970 GMT): %d\\n",
pBuf4->usri4_acct_expires);
wprintf(L"\\tMax storage: %d\\n", pBuf4->usri4_max_storage);
wprintf(L"\\tUnits per week: %d\\n",
pBuf4->usri4_units_per_week);
wprintf(L"\\tLogon hours:");
for (j = 0; j < 21; j++)
   {
printf(" %x", (BYTE) pBuf4->usri4_logon_hours[j]);
}
wprintf(L"\\n");
wprintf(L"\\tBad password count: %d\\n",
pBuf4->usri4_bad_pw_count);
wprintf(L"\\tNumber of logons: %d\\n",
pBuf4->usri4_num_logons);
wprintf(L"\\tLogon server: %s\\n", pBuf4->usri4_logon_server);
wprintf(L"\\tCountry code: %d\\n", pBuf4->usri4_country_code);
wprintf(L"\\tCode page: %d\\n", pBuf4->usri4_code_page);
if (ConvertSidToStringSid
(pBuf4->usri4_user_sid, &sStringSid))
   {
wprintf(L"\\tUser SID: %s\\n", sStringSid);
LocalFree(sStringSid);
}
   else
wprintf(L"ConvertSidToSTringSid failed with error %d\\n",
GetLastError());
wprintf(L"\\tPrimary group ID: %d\\n",
pBuf4->usri4_primary_group_id);
wprintf(L"\\tProfile: %s\\n", pBuf4->usri4_profile);
wprintf(L"\\tHome directory drive letter: %s\\n",
pBuf4->usri4_home_dir_drive);
wprintf(L"\\tPassword expired information: %d\\n",
pBuf4->usri4_password_expired);
break;
case 10:
pBuf10 = (LPUSER_INFO_10) pBuf;
wprintf(L"\\tUser account name: %s\\n", pBuf10->usri10_name);
wprintf(L"\\tComment: %s\\n", pBuf10->usri10_comment);
wprintf(L"\\tUser comment: %s\\n",
pBuf10->usri10_usr_comment);
wprintf(L"\\tFull name: %s\\n", pBuf10->usri10_full_name);
break;
case 11:
pBuf11 = (LPUSER_INFO_11) pBuf;
wprintf(L"\\tUser account name: %s\\n", pBuf11->usri11_name);
wprintf(L"\\tComment: %s\\n", pBuf11->usri11_comment);
wprintf(L"\\tUser comment: %s\\n",
pBuf11->usri11_usr_comment);
wprintf(L"\\tFull name: %s\\n", pBuf11->usri11_full_name);
wprintf(L"\\tPrivilege level: %d\\n", pBuf11->usri11_priv);
wprintf(L"\\tAuth flags (in hex): %x\\n",
pBuf11->usri11_auth_flags);
wprintf(L"\\tPassword age (seconds): %d\\n",
pBuf11->usri11_password_age);
wprintf(L"\\tHome directory: %s\\n", pBuf11->usri11_home_dir);
wprintf(L"\\tParameters: %s\\n", pBuf11->usri11_parms);
wprintf
(L"\\tLast logon (seconds since January 1, 1970 GMT): %d\\n",
pBuf11->usri11_last_logon);
wprintf
(L"\\tLast logoff (seconds since January 1, 1970 GMT): %d\\n",
pBuf11->usri11_last_logoff);
wprintf(L"\\tBad password count: %d\\n",
pBuf11->usri11_bad_pw_count);
wprintf(L"\\tNumber of logons: %d\\n",
pBuf11->usri11_num_logons);
wprintf(L"\\tLogon server: %s\\n",
pBuf11->usri11_logon_server);
wprintf(L"\\tCountry code: %d\\n",
pBuf11->usri11_country_code);
wprintf(L"\\tWorkstations: %s\\n",
pBuf11->usri11_workstations);
wprintf(L"\\tMax storage: %d\\n", pBuf11->usri11_max_storage);
wprintf(L"\\tUnits per week: %d\\n",
pBuf11->usri11_units_per_week);
wprintf(L"\\tLogon hours:");
for (j = 0; j < 21; j++)
   {
printf(" %x", (BYTE) pBuf11->usri11_logon_hours[j]);
}
wprintf(L"\\n");
wprintf(L"\\tCode page: %d\\n", pBuf11->usri11_code_page);
break;
case 20:
pBuf20 = (LPUSER_INFO_20) pBuf;
wprintf(L"\\tUser account name: %s\\n", pBuf20->usri20_name);
wprintf(L"\\tFull name: %s\\n", pBuf20->usri20_full_name);
wprintf(L"\\tComment: %s\\n", pBuf20->usri20_comment);
wprintf(L"\\tFlags (in hex): %x\\n", pBuf20->usri20_flags);
wprintf(L"\\tUser ID: %u\\n", pBuf20->usri20_user_id);
break;
case 23:
pBuf23 = (LPUSER_INFO_23) pBuf;
wprintf(L"\\tUser account name: %s\\n", pBuf23->usri23_name);
wprintf(L"\\tFull name: %s\\n", pBuf23->usri23_full_name);
wprintf(L"\\tComment: %s\\n", pBuf23->usri23_comment);
wprintf(L"\\tFlags (in hex): %x\\n", pBuf23->usri23_flags);
if (ConvertSidToStringSid
(pBuf23->usri23_user_sid, &sStringSid))
   {
wprintf(L"\\tUser SID: %s\\n", sStringSid);
LocalFree(sStringSid);
}
   else
wprintf(L"ConvertSidToSTringSid failed with error %d\\n",
GetLastError());
break;
default:
break;
}
}
}
// Otherwise, print the system error.
//
else
fprintf(stderr, "NetUserGetinfo failed with error: %d\\n", nStatus);
//
// Free the allocated memory.
//
if (pBuf != NULL)
NetApiBufferFree(pBuf);
switch (i)
  {
case 0:
case 1:
case 10:
i++;
break;
case 2:
i = 4;
break;
case 4:
i = 10;
break;
case 11:
i = 20;
break;
case 20:
i = 23;
break;
default:
i = 24;
break;
}
}
return 0;
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmaccess.h(包括Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
参见
网络管理概述
网络管理功能
用户功能
NetUserSetInfo
NetUserGetGroups
NetUserEnum
USER_INFO_0
USER_INFO_1
USER_INFO_2
USER_INFO_4
USER_INFO_10
USER_INFO_11
USER_INFO_23
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月13日
==英文原文==NetUserGetInfo Function
The NetUserGetInfo function retrieves information about a particular user account on a server.
Syntax
C++
NET_API_STATUS NetUserGetInfo(
__in LPCWSTR servername,
__in LPCWSTR username,
__in DWORD level,
__out LPBYTE *bufptr
);
Parameters
servername [in]
A pointer to a constant string that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is NULL, the local computer is used.
username [in]
A pointer to a constant string that specifies the name of the user account for which to return information. For more information, see the following Remarks section.
level [in]
The information level of the data. This parameter can be one of the following values.
ValueMeaning
0Return the user account name. The bufptr parameter points to a USER_INFO_0 structure.
1Return detailed information about the user account. The bufptr parameter points to a USER_INFO_1 structure.
2Return detailed information and additional attributes about the user account. The bufptr parameter points to a USER_INFO_2 structure.
3Return detailed information and additional attributes about the user account. This level is valid only on servers. The bufptr parameter points to a USER_INFO_3 structure. Note that it is recommended that you use USER_INFO_4 instead.
4Return detailed information and additional attributes about the user account. This level is valid only on servers. The bufptr parameter points to a USER_INFO_4 structure.
Windows 2000: This level is not supported.
10Return user and account names and comments. The bufptr parameter points to a USER_INFO_10 structure.
11Return detailed information about the user account. The bufptr parameter points to a USER_INFO_11 structure.
20Return the user's name and identifier and various account attributes. The bufptr parameter points to a USER_INFO_20 structure. Note that on Windows XP and later, it is recommended that you use USER_INFO_23 instead.
23Return the user's name and identifier and various account attributes. The bufptr parameter points to a USER_INFO_23 structure.
Windows 2000: This level is not supported.

bufptr [out]
A pointer to the buffer that receives the data. The format of this data depends on the value of the level parameter. This buffer is allocated by the system and must be freed using the NetApiBufferFree function. For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths .
Return Value
If the function succeeds, the return value is NERR_Success.
If the function fails, the return value can be one of the following error codes.
Return codeDescription
ERROR_ACCESS_DENIEDThe user does not have access to the requested information.
ERROR_BAD_NETPATHThe network path specified in the servername parameter was not found.
ERROR_INVALID_LEVELThe value specified for the level parameter is invalid.
NERR_InvalidComputerThe computer name is invalid.
NERR_UserNotFoundThe user name could not be found.

Remarks
If you are programming for Active Directory, you may be able to call certain Active Directory Service Interface (ADSI) methods to achieve the same functionality you can achieve by calling the network management user functions. For more information, see IADsUser and IADsComputer .
If you call this function on a domain controller that is running Active Directory, access is allowed or denied based on the access control list (ACL) for the securable object . The default ACL permits all authenticated users and members of the " Pre-Windows2000 compatible access " group to view the information. If you call this function on a member server or workstation, all authenticated users can view the information. For information about anonymous access and restricting anonymous access on these platforms, see Security Requirements for the Network Management Functions . For more information on ACLs, ACEs, and access tokens, see Access Control Model .
The security descriptor of the User object is used to perform the access check for this function.
User account names are limited to 20 characters and group names are limited to 256 characters. In addition, account names cannot be terminated by a period and they cannot include commas or any of the following printable characters: ", /, \\, [, ], :, |, <, >, +, =, ;, ?, *. Names also cannot include characters in the range 1-31, which are nonprintable.
Examples
The following code sample demonstrates how to retrieve information about a particular user account with a call to the NetUserGetInfo function. The sample calls NetUserGetInfo, specifying various information levels . If the call succeeds, the code prints information about the user account. Finally, the sample frees the memory allocated for the information buffer.
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "advapi32.lib")
#pragma comment(lib, "netapi32.lib")
#include
#include
#include
#include
#include /* for ConvertSidToStringSid function */
int wmain(int argc, wchar_t * argv[])
{
DWORD dwLevel = 0;
LPUSER_INFO_0 pBuf = NULL;
LPUSER_INFO_1 pBuf1 = NULL;
LPUSER_INFO_2 pBuf2 = NULL;
LPUSER_INFO_3 pBuf3 = NULL;
LPUSER_INFO_4 pBuf4 = NULL;
LPUSER_INFO_10 pBuf10 = NULL;
LPUSER_INFO_11 pBuf11 = NULL;
LPUSER_INFO_20 pBuf20 = NULL;
LPUSER_INFO_23 pBuf23 = NULL;
NET_API_STATUS nStatus;
LPTSTR sStringSid = NULL;
int i = 0;
int j = 0;
if (argc != 3)
 {
fwprintf(stderr, L"Usage: %s \\\\\\\\ServerName UserName\\n", argv[0]);
exit(1);
}
while (i < 24)
 {
//
// Call the NetUserGetInfo function.
//
dwLevel = i;
wprintf
(L"\\nCalling NetUserGetinfo with Servername=%s Username=%s Level=%d\\n",
argv[1], argv[2], dwLevel);
nStatus = NetUserGetInfo(argv[1], argv[2], dwLevel, (LPBYTE *) & pBuf);
//
// If the call succeeds, print the user information.
//
if (nStatus == NERR_Success)
  {
if (pBuf != NULL)
 {
switch (i)
  {
case 0:
wprintf(L"\\tUser account name: %s\\n", pBuf->usri0_name);
break;
case 1:
pBuf1 = (LPUSER_INFO_1) pBuf;
wprintf(L"\\tUser account name: %s\\n", pBuf1->usri1_name);
wprintf(L"\\tPassword: %s\\n", pBuf1->usri1_password);
wprintf(L"\\tPassword age (seconds): %d\\n",
pBuf1->usri1_password_age);
wprintf(L"\\tPrivilege level: %d\\n", pBuf1->usri1_priv);
wprintf(L"\\tHome directory: %s\\n", pBuf1->usri1_home_dir);
wprintf(L"\\tUser comment: %s\\n", pBuf1->usri1_comment);
wprintf(L"\\tFlags (in hex): %x\\n", pBuf1->usri1_flags);
wprintf(L"\\tScript path: %s\\n", pBuf1->usri1_script_path);
break;
case 2:
pBuf2 = (LPUSER_INFO_2) pBuf;
wprintf(L"\\tUser account name: %s\\n", pBuf2->usri2_name);
wprintf(L"\\tPassword: %s\\n", pBuf2->usri2_password);
wprintf(L"\\tPassword age (seconds): %d\\n",
pBuf2->usri2_password_age);
wprintf(L"\\tPrivilege level: %d\\n", pBuf2->usri2_priv);
wprintf(L"\\tHome directory: %s\\n", pBuf2->usri2_home_dir);
wprintf(L"\\tComment: %s\\n", pBuf2->usri2_comment);
wprintf(L"\\tFlags (in hex): %x\\n", pBuf2->usri2_flags);
wprintf(L"\\tScript path: %s\\n", pBuf2->usri2_script_path);
wprintf(L"\\tAuth flags (in hex): %x\\n",
pBuf2->usri2_auth_flags);
wprintf(L"\\tFull name: %s\\n", pBuf2->usri2_full_name);
wprintf(L"\\tUser comment: %s\\n", pBuf2->usri2_usr_comment);
wprintf(L"\\tParameters: %s\\n", pBuf2->usri2_parms);
wprintf(L"\\tWorkstations: %s\\n", pBuf2->usri2_workstations);
wprintf
(L"\\tLast logon (seconds since January 1, 1970 GMT): %d\\n",
pBuf2->usri2_last_logon);
wprintf
(L"\\tLast logoff (seconds since January 1, 1970 GMT): %d\\n",
pBuf2->usri2_last_logoff);
wprintf
(L"\\tAccount expires (seconds since January 1, 1970 GMT): %d\\n",
pBuf2->usri2_acct_expires);
wprintf(L"\\tMax storage: %d\\n", pBuf2->usri2_max_storage);
wprintf(L"\\tUnits per week: %d\\n",
pBuf2->usri2_units_per_week);
wprintf(L"\\tLogon hours:");
for (j = 0; j < 21; j++)
   {
printf(" %x", (BYTE) pBuf2->usri2_logon_hours[j]);
}
wprintf(L"\\n");
wprintf(L"\\tBad password count: %d\\n",
pBuf2->usri2_bad_pw_count);
wprintf(L"\\tNumber of logons: %d\\n",
pBuf2->usri2_num_logons);
wprintf(L"\\tLogon server: %s\\n", pBuf2->usri2_logon_server);
wprintf(L"\\tCountry code: %d\\n", pBuf2->usri2_country_code);
wprintf(L"\\tCode page: %d\\n", pBuf2->usri2_code_page);
break;
case 4:
pBuf4 = (LPUSER_INFO_4) pBuf;
wprintf(L"\\tUser account name: %s\\n", pBuf4->usri4_name);
wprintf(L"\\tPassword: %s\\n", pBuf4->usri4_password);
wprintf(L"\\tPassword age (seconds): %d\\n",
pBuf4->usri4_password_age);
wprintf(L"\\tPrivilege level: %d\\n", pBuf4->usri4_priv);
wprintf(L"\\tHome directory: %s\\n", pBuf4->usri4_home_dir);
wprintf(L"\\tComment: %s\\n", pBuf4->usri4_comment);
wprintf(L"\\tFlags (in hex): %x\\n", pBuf4->usri4_flags);
wprintf(L"\\tScript path: %s\\n", pBuf4->usri4_script_path);
wprintf(L"\\tAuth flags (in hex): %x\\n",
pBuf4->usri4_auth_flags);
wprintf(L"\\tFull name: %s\\n", pBuf4->usri4_full_name);
wprintf(L"\\tUser comment: %s\\n", pBuf4->usri4_usr_comment);
wprintf(L"\\tParameters: %s\\n", pBuf4->usri4_parms);
wprintf(L"\\tWorkstations: %s\\n", pBuf4->usri4_workstations);
wprintf
(L"\\tLast logon (seconds since January 1, 1970 GMT): %d\\n",
pBuf4->usri4_last_logon);
wprintf
(L"\\tLast logoff (seconds since January 1, 1970 GMT): %d\\n",
pBuf4->usri4_last_logoff);
wprintf
(L"\\tAccount expires (seconds since January 1, 1970 GMT): %d\\n",
pBuf4->usri4_acct_expires);
wprintf(L"\\tMax storage: %d\\n", pBuf4->usri4_max_storage);
wprintf(L"\\tUnits per week: %d\\n",
pBuf4->usri4_units_per_week);
wprintf(L"\\tLogon hours:");
for (j = 0; j < 21; j++)
   {
printf(" %x", (BYTE) pBuf4->usri4_logon_hours[j]);
}
wprintf(L"\\n");
wprintf(L"\\tBad password count: %d\\n",
pBuf4->usri4_bad_pw_count);
wprintf(L"\\tNumber of logons: %d\\n",
pBuf4->usri4_num_logons);
wprintf(L"\\tLogon server: %s\\n", pBuf4->usri4_logon_server);
wprintf(L"\\tCountry code: %d\\n", pBuf4->usri4_country_code);
wprintf(L"\\tCode page: %d\\n", pBuf4->usri4_code_page);
if (ConvertSidToStringSid
(pBuf4->usri4_user_sid, &sStringSid))
   {
wprintf(L"\\tUser SID: %s\\n", sStringSid);
LocalFree(sStringSid);
}
   else
wprintf(L"ConvertSidToSTringSid failed with error %d\\n",
GetLastError());
wprintf(L"\\tPrimary group ID: %d\\n",
pBuf4->usri4_primary_group_id);
wprintf(L"\\tProfile: %s\\n", pBuf4->usri4_profile);
wprintf(L"\\tHome directory drive letter: %s\\n",
pBuf4->usri4_home_dir_drive);
wprintf(L"\\tPassword expired information: %d\\n",
pBuf4->usri4_password_expired);
break;
case 10:
pBuf10 = (LPUSER_INFO_10) pBuf;
wprintf(L"\\tUser account name: %s\\n", pBuf10->usri10_name);
wprintf(L"\\tComment: %s\\n", pBuf10->usri10_comment);
wprintf(L"\\tUser comment: %s\\n",
pBuf10->usri10_usr_comment);
wprintf(L"\\tFull name: %s\\n", pBuf10->usri10_full_name);
break;
case 11:
pBuf11 = (LPUSER_INFO_11) pBuf;
wprintf(L"\\tUser account name: %s\\n", pBuf11->usri11_name);
wprintf(L"\\tComment: %s\\n", pBuf11->usri11_comment);
wprintf(L"\\tUser comment: %s\\n",
pBuf11->usri11_usr_comment);
wprintf(L"\\tFull name: %s\\n", pBuf11->usri11_full_name);
wprintf(L"\\tPrivilege level: %d\\n", pBuf11->usri11_priv);
wprintf(L"\\tAuth flags (in hex): %x\\n",
pBuf11->usri11_auth_flags);
wprintf(L"\\tPassword age (seconds): %d\\n",
pBuf11->usri11_password_age);
wprintf(L"\\tHome directory: %s\\n", pBuf11->usri11_home_dir);
wprintf(L"\\tParameters: %s\\n", pBuf11->usri11_parms);
wprintf
(L"\\tLast logon (seconds since January 1, 1970 GMT): %d\\n",
pBuf11->usri11_last_logon);
wprintf
(L"\\tLast logoff (seconds since January 1, 1970 GMT): %d\\n",
pBuf11->usri11_last_logoff);
wprintf(L"\\tBad password count: %d\\n",
pBuf11->usri11_bad_pw_count);
wprintf(L"\\tNumber of logons: %d\\n",
pBuf11->usri11_num_logons);
wprintf(L"\\tLogon server: %s\\n",
pBuf11->usri11_logon_server);
wprintf(L"\\tCountry code: %d\\n",
pBuf11->usri11_country_code);
wprintf(L"\\tWorkstations: %s\\n",
pBuf11->usri11_workstations);
wprintf(L"\\tMax storage: %d\\n", pBuf11->usri11_max_storage);
wprintf(L"\\tUnits per week: %d\\n",
pBuf11->usri11_units_per_week);
wprintf(L"\\tLogon hours:");
for (j = 0; j < 21; j++)
   {
printf(" %x", (BYTE) pBuf11->usri11_logon_hours[j]);
}
wprintf(L"\\n");
wprintf(L"\\tCode page: %d\\n", pBuf11->usri11_code_page);
break;
case 20:
pBuf20 = (LPUSER_INFO_20) pBuf;
wprintf(L"\\tUser account name: %s\\n", pBuf20->usri20_name);
wprintf(L"\\tFull name: %s\\n", pBuf20->usri20_full_name);
wprintf(L"\\tComment: %s\\n", pBuf20->usri20_comment);
wprintf(L"\\tFlags (in hex): %x\\n", pBuf20->usri20_flags);
wprintf(L"\\tUser ID: %u\\n", pBuf20->usri20_user_id);
break;
case 23:
pBuf23 = (LPUSER_INFO_23) pBuf;
wprintf(L"\\tUser account name: %s\\n", pBuf23->usri23_name);
wprintf(L"\\tFull name: %s\\n", pBuf23->usri23_full_name);
wprintf(L"\\tComment: %s\\n", pBuf23->usri23_comment);
wprintf(L"\\tFlags (in hex): %x\\n", pBuf23->usri23_flags);
if (ConvertSidToStringSid
(pBuf23->usri23_user_sid, &sStringSid))
   {
wprintf(L"\\tUser SID: %s\\n", sStringSid);
LocalFree(sStringSid);
}
   else
wprintf(L"ConvertSidToSTringSid failed with error %d\\n",
GetLastError());
break;
default:
break;
}
}
}
// Otherwise, print the system error.
//
else
fprintf(stderr, "NetUserGetinfo failed with error: %d\\n", nStatus);
//
// Free the allocated memory.
//
if (pBuf != NULL)
NetApiBufferFree(pBuf);
switch (i)
  {
case 0:
case 1:
case 10:
i++;
break;
case 2:
i = 4;
break;
case 4:
i = 10;
break;
case 11:
i = 20;
break;
case 20:
i = 23;
break;
default:
i = 24;
break;
}
}
return 0;
}
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderLmaccess.h (include Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
See Also
Network Management Overview
Network Management Functions
User Functions
NetUserSetInfo
NetUserGetGroups
NetUserEnum
USER_INFO_0
USER_INFO_1
USER_INFO_2
USER_INFO_4
USER_INFO_10
USER_INFO_11
USER_INFO_23
Send comments about this topic to Microsoft
Build date: 8/13/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa370654(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:21:21