网站首页  词典首页

请输入您要查询的函数:

 

术语 netusersetinfo
释义 NetUserSetInfo
语法:
C++
NET_API_STATUS NetUserSetInfo(
__in LPCWSTR servername,
__in LPCWSTR username,
__in DWORD level,
__in LPBYTE buf,
__out LPDWORD parm_err
);
NetUserSetInfo功能
该NetUserSetInfo函数设置的用户帐户的参数。
参数
服务器名 [in]
指针常量字符串指定的DNS或NetBIOS的远程服务器上的功能是执行的名称。如果该参数为NULL,则使用本地计算机。
用户名 [in]
指针常量字符串指定用户帐户的设置信息的名称。有关详细信息,请参阅下面的备注部分。
Level [in]
指定的数据信息的Level。此参数可以是下列值之一。
ValueMeaning
0Specifies用户帐户的名称。在buf参数指向一个USER_INFO_0结构。使用此结构指定一个新的组名。有关详细信息,请参阅下面的备注部分。
1Specifies的详细信息的用户帐户。在buf参数指向一个USER_INFO_1结构。
2SpecifiesLevel1的信息和用户帐户的其他属性。在buf参数指向一个USER_INFO_2结构。
3Specifies第二级信息和用户帐户的其他属性。这个级别只适用于服务器。在buf参数指向一个USER_INFO_3结构。请注意,建议您使用USER_INFO_4代替。
4Specifies第二级信息和用户帐户的其他属性。这个级别只适用于服务器。在buf参数指向一个USER_INFO_4结构。
21Specifies单向加密LAN Manager的2.X的兼容密码。在buf参数指向一个USER_INFO_21结构。
22Specifies的详细信息的用户帐户。在buf参数指向一个USER_INFO_22结构。
1003Specifies用户密码。在buf参数指向一个USER_INFO_1003结构。
1005Specifies用户权限级别。在buf参数指向一个USER_INFO_1005结构。
1006Specifies的路径,为用户的主目录。在buf参数指向一个USER_INFO_1006结构。
1007Specifies评论联想到用户帐户。在buf参数指向一个USER_INFO_1007结构。
1008Specifies用户帐户属性。在buf参数指向一个USER_INFO_1008结构。
1009Specifies的路径为用户的登录脚本文件。在buf参数指向一个USER_INFO_1009结构。
1010Specifies用户的操作员权限。在buf参数指向一个USER_INFO_1010结构。
1011Specifies用户的全名。在buf参数指向一个USER_INFO_1011结构。
1012Specifies评论联想到用户。在buf参数指向一个USER_INFO_1012结构。
1014Specifies工作站的用户可以登录的名字。在buf参数指向一个USER_INFO_1014结构。
1017Specifies当用户帐户到期。在buf参数指向一个USER_INFO_1017结构。
1020Specifies时代在此期间,用户可以登录。在buf参数指向一个USER_INFO_1020结构。
1024Specifies用户的国家/地区代码。在buf参数指向一个USER_INFO_1024结构。
1051Specifies一个全局组,代表注册的用户相对标识符。在buf参数指向一个USER_INFO_1051结构。
1052Specifies到一个网络用户的配置文件路径。在buf参数指向一个USER_INFO_1052结构。
1053Specifies驱动器号分配给用户的主目录。在buf参数指向一个USER_INFO_1053结构。
缓冲带 [in]
缓冲区指针指定的数据。这一数据格式取决于Level的参数值。有关更多信息,请参阅网络管理功能的缓冲器。
parm_err [out]
指针的值,它接收了用户信息的结构的第一个成员的索引导致ERROR_INVALID_PARAMETER。如果该参数为NULL,则指数不返回的错误。有关详细信息,请参阅下面的备注部分。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值可以是下面的错误代码之一。
返回codeDescription
ERROR_ACCESS_DENIEDThe用户没有获得所需的信息。
函数的参数ERROR_INVALID_PARAMETEROne是无效的。有关详细信息,请参阅下面的备注部分。
NERR_InvalidComputerThe计算机名无效。
NERR_NotPrimaryThe操作只允许在该域的主域控制器。
NERR_SpeGroupOpThe操作是不允许在指定的特殊群体,这些用户组,管理员组,本地组,或来宾组。
NERR_LastAdminThe操作不允许在最后的管理帐户。
NERR_BadPasswordThe共享名或密码无效。
NERR_PasswordTooShortThe密码少于需要。 (密码也可以太长,太在其历史上最近的变化,没有足够的独特的字符,或一个新的密码不符合政策的要求。)
NERR_UserNotFoundThe用户名找不到。
备注
如果您是Active Directory的程序,您可以调用某些Active Directory服务接口(ADSI)的方法来达到同样的功能,您可以通过调用用户的网络管理功能。有关更多信息,请参阅IADsUser和IADsComputer。
如果您调用域控制器上运行Active Directory的这一功能,允许访问或拒绝的访问控制列表的安全对象(ACL)的基础。默认的ACL只允许域管理员和Account Operators调用此函数。在成员服务器或工作站,只有Administrators和Power Users可以调用这个函数。有关更多信息,请参阅的网络管理功能的安全要求。欲了解更多有关的ACL,ACE的,和访问令牌信息,请访问控制模型。
该用户对象的安全描述符用于执行此函数访问检查。
只有用户或应用程序有管理权限可以调用NetUserSetInfo函数来更改用户的密码。当管理员要求NetUserSetInfo,唯一的限制,适用的是,新密码的长度必须与系统的情态一致。用户或应用程序知道用户的当前密码可以调用NetUserChangePassword的函数来更改密码。如需有关通话功能,需要管理员权限的信息,请运行特权。
系统管理员本地组成员可以设置用户帐户的任何修改的内容。所有用户都可以设置USER_INFO_2结构usri2_country_code成员(以及USER_INFO_1024结构usri1024_country_code成员)为自己的帐户。
一个帐户操作的本地组的成员不能设置一个管理员级的帐户资料,给现有的帐户管理员权限,或更改任何帐户操作权限。如果您尝试更改权限级别或管理员安全数据库权限禁用最后帐户,(安全帐户管理器(SAM)数据库,或在域控制器的情况下,Active Directory)中,该NetUserSetInfo函数失败并返回NERR_LastAdmin。
设置以下用户帐户控制标志,下列特权和控制访问权限是必需的。
帐户控制flagPrivilege或权利要求
UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATIONSeEnableDelegationPrivilege特权,这是默认情况下授予管理员。
UF_TRUSTED_FOR_DELEGATIONSeEnableDelegationPrivilege。
UF_PASSWD_NOTREQD“更新密码不要求”的域对象,它被授予默认身份验证的用户访问控制权。
UF_DONT_EXPIRE_PASSWD“Unexpire密码”控制域对象,它被授予默认身份验证的用户访问权利。
UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED“启用每用户可逆加密密码”控制域对象,它被授予默认身份验证的用户访问权利。
UF_SERVER_TRUST_ACCOUNT“添加/删除域副本”控制域对象,这是默认情况下授予管理员访问权限。
对于特权常数的列表,请参阅授权常量。
正确的方法来指定帐户的新名称,就调用USER_INFO_0 NetUserSetInfo,并指定新值使用usri0_name成员。如果您调用与其他信息LevelNetUserSetInfo并指定一个值使用usriX_name的成员,该值将被忽略。
请注意,要NetUserSetInfo电话只能更改用户帐户,网络服务器创建主目录。
如果NetUserSetInfo函数返回ERROR_INVALID_PARAMETER,您可以使用parm_err参数表明了用户的信息结构的第一个成员是无效的。 (用户信息结构开始USER_INFO_以及它的形式是指定的Level参数。)下表列出了可以返回的parm_err参数和相应的结构成员,在错误的价值观。 (前缀usri * _表明,成员国可以开始与多个前缀,例如,usri10_或usri1003_。)
ValueMember
USER_NAME_PARMNUMusri * _name
USER_PASSWORD_PARMNUMusri * _password
USER_PASSWORD_AGE_PARMNUMusri * _password_age
USER_PRIV_PARMNUMusri * _priv
USER_HOME_DIR_PARMNUMusri * _home_dir
USER_COMMENT_PARMNUMusri * _comment
USER_FLAGS_PARMNUMusri * _flags
USER_SCRIPT_PATH_PARMNUMusri * _script_path
USER_AUTH_FLAGS_PARMNUMusri * _auth_flags
USER_FULL_NAME_PARMNUMusri * _full_name
USER_USR_COMMENT_PARMNUMusri * _usr_comment
USER_PARMS_PARMNUMusri * _parms
USER_WORKSTATIONS_PARMNUMusri * _workstations
USER_LAST_LOGON_PARMNUMusri * _last_logon
USER_LAST_LOGOFF_PARMNUMusri * _last_logoff
USER_ACCT_EXPIRES_PARMNUMusri * _acct_expires
USER_MAX_STORAGE_PARMNUMusri * _max_storage
USER_UNITS_PER_WEEK_PARMNUMusri * _units_per_week
USER_LOGON_HOURS_PARMNUMusri * _logon_hours
USER_PAD_PW_COUNT_PARMNUMusri * _bad_pw_count
USER_NUM_LOGONS_PARMNUMusri * _num_logons
USER_LOGON_SERVER_PARMNUMusri * _logon_server
USER_COUNTRY_CODE_PARMNUMusri * _country_code
USER_CODE_PAGE_PARMNUMusri * _code_page
USER_PRIMARY_GROUP_PARMNUMusri * _primary_group_id
USER_PROFILE_PARMNUMusri * _profile
USER_HOME_DIR_DRIVE_PARMNUMusri * _home_dir_drive
用户帐户名称被限制为20个字符和组名称被限制为256个字符。此外,帐户名称不能终止的期间,他们不能包含逗号或以下打印字符:“,/,\\,[,]:,|,”,“+,=,,,?, *.名称也不能包括在1-31范围内,这些非打印字符。
实例
下面的代码示例演示了如何禁用,以该NetUserSetInfo函数调用一个用户帐户。填充的代码示例在USER_INFO_1008结构usri1008_flags成员,指定值UF_ACCOUNTDISABLE。然后,该示例调用NetUserSetInfo,指定信息化Level0。
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib")
#include
#include
#include
int wmain(int argc, wchar_t *argv[])
{
DWORD dwLevel = 1008;
USER_INFO_1008 ui;
NET_API_STATUS nStatus;
if (argc != 3)
{
fwprintf(stderr, L"Usage: %s \\\\\\\\ServerName UserName\\n", argv[0]);
exit(1);
}
// Fill in the USER_INFO_1008 structure member.
// UF_SCRIPT: required.
//
ui.usri1008_flags = UF_SCRIPT | UF_ACCOUNTDISABLE;
//
// Call the NetUserSetInfo function
// to disable the account, specifying level 1008.
//
nStatus = NetUserSetInfo(argv[1],
argv[2],
dwLevel,
(LPBYTE)&ui,
NULL);
//
// Display the result of the call.
//
if (nStatus == NERR_Success)
fwprintf(stderr, L"User account %s has been disabled\\n", argv[2]);
else
fprintf(stderr, "A system error has occurred: %d\\n", nStatus);
return 0;
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmaccess.h(包括Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
参见
网络管理概述
网络管理功能
用户功能
NetUserGetInfo
USER_INFO_0
USER_INFO_1
USER_INFO_2
USER_INFO_4
USER_INFO_21
USER_INFO_22
USER_INFO_1003
USER_INFO_1005
USER_INFO_1006
USER_INFO_1007
USER_INFO_1008
USER_INFO_1009
USER_INFO_1010
USER_INFO_1011
USER_INFO_1012
USER_INFO_1013
USER_INFO_1014
USER_INFO_1017
USER_INFO_1020
USER_INFO_1024
USER_INFO_1051
USER_INFO_1052
USER_INFO_1053
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月13日
==英文原文==NetUserSetInfo Function
The NetUserSetInfo function sets the parameters of a user account.
Syntax
C++
NET_API_STATUS NetUserSetInfo(
__in LPCWSTR servername,
__in LPCWSTR username,
__in DWORD level,
__in LPBYTE buf,
__out LPDWORD parm_err
);
Parameters
servername [in]
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]
Pointer to a constant string that specifies the name of the user account for which to set information. For more information, see the following Remarks section.
level [in]
Specifies the information level of the data. This parameter can be one of the following values.
ValueMeaning
0Specifies the user account name. The buf parameter points to a USER_INFO_0 structure. Use this structure to specify a new group name. For more information, see the following Remarks section.
1Specifies detailed information about the user account. The buf parameter points to a USER_INFO_1 structure.
2Specifies level one information and additional attributes about the user account. The buf parameter points to a USER_INFO_2 structure.
3Specifies level two information and additional attributes about the user account. This level is valid only on servers. The buf parameter points to a USER_INFO_3 structure. Note that it is recommended that you use USER_INFO_4 instead.
4Specifies level two information and additional attributes about the user account. This level is valid only on servers. The buf parameter points to a USER_INFO_4 structure.
21Specifies a one-way encrypted LAN Manager 2.x-compatible password. The buf parameter points to a USER_INFO_21 structure.
22Specifies detailed information about the user account. The buf parameter points to a USER_INFO_22 structure.
1003Specifies a user password. The buf parameter points to a USER_INFO_1003 structure.
1005Specifies a user privilege level. The buf parameter points to a USER_INFO_1005 structure.
1006Specifies the path of the home directory for the user. The buf parameter points to a USER_INFO_1006 structure.
1007Specifies a comment to associate with the user account. The buf parameter points to a USER_INFO_1007 structure.
1008Specifies user account attributes. The buf parameter points to a USER_INFO_1008 structure.
1009Specifies the path for the user's logon script file. The buf parameter points to a USER_INFO_1009 structure.
1010Specifies the user's operator privileges. The buf parameter points to a USER_INFO_1010 structure.
1011Specifies the full name of the user. The buf parameter points to a USER_INFO_1011 structure.
1012Specifies a comment to associate with the user. The buf parameter points to a USER_INFO_1012 structure.
1014Specifies the names of workstations from which the user can log on. The buf parameter points to a USER_INFO_1014 structure.
1017Specifies when the user account expires. The buf parameter points to a USER_INFO_1017 structure.
1020Specifies the times during which the user can log on. The buf parameter points to a USER_INFO_1020 structure.
1024Specifies the user's country/region code. The buf parameter points to a USER_INFO_1024 structure.
1051Specifies the relative identifier of a global group that represents the enrolled user. The buf parameter points to a USER_INFO_1051 structure.
1052Specifies the path to a network user's profile. The buf parameter points to a USER_INFO_1052 structure.
1053Specifies the drive letter assigned to the user's home directory. The buf parameter points to a USER_INFO_1053 structure.

buf [in]
Pointer to the buffer that specifies the data. The format of this data depends on the value of the level parameter. For more information, see Network Management Function Buffers .
parm_err [out]
Pointer to a value that receives the index of the first member of the user information structure that causes ERROR_INVALID_PARAMETER. If this parameter is NULL, the index is not returned on error. For more information, see the following Remarks section.
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_INVALID_PARAMETEROne of the function parameters is invalid. For more information, see the following Remarks section.
NERR_InvalidComputerThe computer name is invalid.
NERR_NotPrimaryThe operation is allowed only on the primary domain controller of the domain.
NERR_SpeGroupOpThe operation is not allowed on specified special groups, which are user groups, admin groups, local groups, or guest groups.
NERR_LastAdminThe operation is not allowed on the last administrative account.
NERR_BadPasswordThe share name or password is invalid.
NERR_PasswordTooShortThe password is shorter than required. (The password could also be too long, be too recent in its change history, not have enough unique characters, or not meet another password policy requirement.)
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 only Domain Admins and Account Operators to call this function. On a member server or workstation, only Administrators and Power Users can call this function. For more information, 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.
Only users or applications having administrative privileges can call the NetUserSetInfo function to change a user's password. When an administrator calls NetUserSetInfo, the only restriction applied is that the new password length must be consistent with system modals. A user or application that knows a user's current password can call the NetUserChangePassword function to change the password. For more information about calling functions that require administrator privileges, see Running with Special Privileges .
Members of the Administrators local group can set any modifiable user account elements. All users can set the usri2_country_code member of the USER_INFO_2 structure (and the usri1024_country_code member of the USER_INFO_1024 structure) for their own accounts.
A member of the Account Operator's local group cannot set details for an Administrators class account, give an existing account Administrator privilege, or change the operator privilege of any account. If you attempt to change the privilege level or disable the last account with Administrator privilege in the security database, (the security accounts manager (SAM) database or, in the case of domain controllers, the Active Directory), the NetUserSetInfo function fails and returns NERR_LastAdmin.
To set the following user account control flags, the following privileges and control access rights are required.
Account control flagPrivilege or right required
UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATIONSeEnableDelegationPrivilege privilege, which is granted to Administrators by default.
UF_TRUSTED_FOR_DELEGATIONSeEnableDelegationPrivilege.
UF_PASSWD_NOTREQD"Update password not required" control access right on the Domain object, which is granted to authenticated users by default.
UF_DONT_EXPIRE_PASSWD"Unexpire password" control access right on the Domain object, which is granted to authenticated users by default.
UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED"Enable per user reversibly encrypted password" control access right on the Domain object, which is granted to authenticated users by default.
UF_SERVER_TRUST_ACCOUNT"Add/remove replica in domain" control access right on the Domain object, which is granted to Administrators by default.

For a list of privilege constants, see Authorization Constants .
The correct way to specify the new name for an account is to call NetUserSetInfo with USER_INFO_0 and to specify the new value using the usri0_name member. If you call NetUserSetInfo with other information levels and specify a value using a usriX_name member, the value is ignored.
Note that calls to NetUserSetInfo can change the home directory only for user accounts that the network server creates.
If the NetUserSetInfo function returns ERROR_INVALID_PARAMETER, you can use the parm_err parameter to indicate the first member of the user information structure that is invalid. (A user information structure begins with USER_INFO_ and its format is specified by the level parameter.) The following table lists the values that can be returned in the parm_err parameter and the corresponding structure member that is in error. (The prefix usri*_ indicates that the member can begin with multiple prefixes, for example, usri10_ or usri1003_.)
ValueMember
USER_NAME_PARMNUMusri*_name
USER_PASSWORD_PARMNUMusri*_password
USER_PASSWORD_AGE_PARMNUMusri*_password_age
USER_PRIV_PARMNUMusri*_priv
USER_HOME_DIR_PARMNUMusri*_home_dir
USER_COMMENT_PARMNUMusri*_comment
USER_FLAGS_PARMNUMusri*_flags
USER_SCRIPT_PATH_PARMNUMusri*_script_path
USER_AUTH_FLAGS_PARMNUMusri*_auth_flags
USER_FULL_NAME_PARMNUMusri*_full_name
USER_USR_COMMENT_PARMNUMusri*_usr_comment
USER_PARMS_PARMNUMusri*_parms
USER_WORKSTATIONS_PARMNUMusri*_workstations
USER_LAST_LOGON_PARMNUMusri*_last_logon
USER_LAST_LOGOFF_PARMNUMusri*_last_logoff
USER_ACCT_EXPIRES_PARMNUMusri*_acct_expires
USER_MAX_STORAGE_PARMNUMusri*_max_storage
USER_UNITS_PER_WEEK_PARMNUMusri*_units_per_week
USER_LOGON_HOURS_PARMNUMusri*_logon_hours
USER_PAD_PW_COUNT_PARMNUMusri*_bad_pw_count
USER_NUM_LOGONS_PARMNUMusri*_num_logons
USER_LOGON_SERVER_PARMNUMusri*_logon_server
USER_COUNTRY_CODE_PARMNUMusri*_country_code
USER_CODE_PAGE_PARMNUMusri*_code_page
USER_PRIMARY_GROUP_PARMNUMusri*_primary_group_id
USER_PROFILE_PARMNUMusri*_profile
USER_HOME_DIR_DRIVE_PARMNUMusri*_home_dir_drive

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 disable a user account with a call to the NetUserSetInfo function. The code sample fills in the usri1008_flags member of the USER_INFO_1008 structure, specifying the value UF_ACCOUNTDISABLE. Then the sample calls NetUserSetInfo, specifying information level 0.
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib")
#include
#include
#include
int wmain(int argc, wchar_t *argv[])
{
DWORD dwLevel = 1008;
USER_INFO_1008 ui;
NET_API_STATUS nStatus;
if (argc != 3)
{
fwprintf(stderr, L"Usage: %s \\\\\\\\ServerName UserName\\n", argv[0]);
exit(1);
}
// Fill in the USER_INFO_1008 structure member.
// UF_SCRIPT: required.
//
ui.usri1008_flags = UF_SCRIPT | UF_ACCOUNTDISABLE;
//
// Call the NetUserSetInfo function
// to disable the account, specifying level 1008.
//
nStatus = NetUserSetInfo(argv[1],
argv[2],
dwLevel,
(LPBYTE)&ui,
NULL);
//
// Display the result of the call.
//
if (nStatus == NERR_Success)
fwprintf(stderr, L"User account %s has been disabled\\n", argv[2]);
else
fprintf(stderr, "A system error has occurred: %d\\n", nStatus);
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
NetUserGetInfo
USER_INFO_0
USER_INFO_1
USER_INFO_2
USER_INFO_4
USER_INFO_21
USER_INFO_22
USER_INFO_1003
USER_INFO_1005
USER_INFO_1006
USER_INFO_1007
USER_INFO_1008
USER_INFO_1009
USER_INFO_1010
USER_INFO_1011
USER_INFO_1012
USER_INFO_1013
USER_INFO_1014
USER_INFO_1017
USER_INFO_1020
USER_INFO_1024
USER_INFO_1051
USER_INFO_1052
USER_INFO_1053
Send comments about this topic to Microsoft
Build date: 8/13/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa370659(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 11:22:14