网站首页  词典首页

请输入您要查询的函数:

 

术语 netuserchangepassword
释义 NetUserChangePassword
语法:
C++
NET_API_STATUS NetUserChangePassword(
__in LPCWSTR domainname,
__in LPCWSTR username,
__in LPCWSTR oldpassword,
__in LPCWSTR newpassword
);
NetUserChangePassword的功能
该NetUserChangePassword的功能改变为指定的网络服务器或域用户的密码。
参数
域名 [in]
指针常量字符串指定的DNS或NetBIOS远程服务器或域上的功能是执行的名称。如果该参数为NULL,则调用方登录域使用。
用户名 [in]
指针常量字符串,指定用户名。该NetUserChangePassword的函数更改指定用户的密码。
如果该参数为NULL,则调用方的登录名使用。有关详细信息,请参阅下面的备注部分。
旧密码 [in]
指针常量字符串指定用户的旧密码。
新密码 [in]
指针常量字符串指定用户的新密码。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值可以是下面的错误代码之一。
返回codeDescription
ERROR_ACCESS_DENIEDThe用户没有获得所需的信息。
ERROR_INVALID_PASSWORDThe用户输入一个无效的密码。
NERR_InvalidComputerThe计算机名无效。
NERR_NotPrimaryThe操作只允许在该域的主域控制器。
NERR_UserNotFoundThe用户名找不到。
NERR_PasswordTooShortThe密码少于需要。 (密码也可以太长,太在其历史上最近的变化,没有足够的独特的字符,或一个新的密码不符合政策的要求。)
备注
如果您是Active Directory的程序,您可以调用某些Active Directory服务接口(ADSI)的方法来达到同样的功能,您可以通过调用用户的网络管理功能。有关更多信息,请参阅IADsUser和IADsComputer。
如果您调用域控制器上运行Active Directory的这一功能,允许访问或拒绝的访问控制列表的安全对象(ACL)的基础。默认的ACL只允许域管理员和Account Operators调用此函数。在成员服务器或工作站,只有Administrators和Power Users可以调用这个函数。用户可以改变他或她自己的密码。有关更多信息,请参阅的网络管理功能的安全要求。欲了解更多有关的ACL,ACE的,和访问令牌信息,请访问控制模型。
该用户对象的安全描述符用于执行此函数访问检查。此外,调用者必须具有“更改用户对象上的密码”控制访问权。这项权利被授予匿名登录和默认每个人。
请注意,该函数取得成功,旧密码参数必须匹配的密码,因为它目前存在的。
在某些情况下,过程调用NetUserChangePassword的功能,还必须启用SE_CHANGE_NOTIFY_NAME特权,否则,NetUserChangePassword的失败,GetLastError返回ERROR_ACCESS_DENIED。这个特权不需要在LocalSystem帐户或帐户是管理员组的成员。默认情况下,SE_CHANGE_NOTIFY_NAME启用了所有用户,但有些管理员可能会停用每个人的特权。欲了解更多有关帐户权限的信息,请参阅特权和授权常数。
见强迫用户更改的代码示例演示如何强制用户更改在下次使用NetUserGetInfo和NetUserSetInfo职能登录密码登录的登录密码。
用户帐户名称被限制为20个字符和组名称被限制为256个字符。此外,帐户名称不能终止的期间,他们不能包含逗号或以下打印字符:“,/,\\,[,]:,|,”,“+,=,,,?, *.名称也不能包括在1-31范围内,这些非打印字符。
实例
下面的代码示例演示如何更改,以在NetUserChangePassword的函数调用用户的密码。所有的函数的参数是必需的。
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib")
#include
#include
#include
int wmain(int argc, wchar_t *argv[])
{
DWORD dwError = 0;
NET_API_STATUS nStatus;
//
// All parameters are required.
//
if (argc != 5)
{
fwprintf(stderr, L"Usage: %s \\\\\\\\ServerName UserName OldPassword NewPassword\\n", argv[0]);
exit(1);
}
//
// Call the NetUserChangePassword function.
//
nStatus = NetUserChangePassword(argv[1], argv[2], argv[3], argv[4]);
//
// If the call succeeds, inform the user.
//
if (nStatus == NERR_Success)
fwprintf(stderr, L"User password has been changed successfully\\n");
//
// Otherwise, print the system error.
//
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
参见
网络管理概述
网络管理功能
用户功能
NetUserSetInfo
NetUserGetInfo
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月13日
==英文原文==NetUserChangePassword Function
The NetUserChangePassword function changes a user's password for a specified network server or domain.
Syntax
C++
NET_API_STATUS NetUserChangePassword(
__in LPCWSTR domainname,
__in LPCWSTR username,
__in LPCWSTR oldpassword,
__in LPCWSTR newpassword
);
Parameters
domainname [in]
Pointer to a constant string that specifies the DNS or NetBIOS name of a remote server or domain on which the function is to execute. If this parameter is NULL, the logon domain of the caller is used.
username [in]
Pointer to a constant string that specifies a user name. The NetUserChangePassword function changes the password for the specified user.
If this parameter is NULL, the logon name of the caller is used. For more information, see the following Remarks section.
oldpassword [in]
Pointer to a constant string that specifies the user's old password.
newpassword [in]
Pointer to a constant string that specifies the user's new password.
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_PASSWORDThe user has entered an invalid password.
NERR_InvalidComputerThe computer name is invalid.
NERR_NotPrimaryThe operation is allowed only on the primary domain controller of the domain.
NERR_UserNotFoundThe user name could not be found.
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.)

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. A user can change his or her own password. 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. In addition, the caller must have the "Change password" control access right on the User object. This right is granted to Anonymous Logon and Everyone by default.
Note that for the function to succeed, the oldpassword parameter must match the password as it currently exists.
In some cases, the process that calls the NetUserChangePassword function must also have the SE_CHANGE_NOTIFY_NAME privilege enabled; otherwise, NetUserChangePassword fails and GetLastError returns ERROR_ACCESS_DENIED. This privilege is not required for the LocalSystem account or for accounts that are members of the administrators group. By default, SE_CHANGE_NOTIFY_NAME is enabled for all users, but some administrators may disable the privilege for everyone. For more information about account privileges, see Privileges and Authorization Constants .
See Forcing a User to Change the Logon Password for a code sample that demonstrates how to force a user to change the logon password on the next logon using the NetUserGetInfo and NetUserSetInfo functions.
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 change a user's password with a call to the NetUserChangePassword function. All parameters to the function are required.
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib")
#include
#include
#include
int wmain(int argc, wchar_t *argv[])
{
DWORD dwError = 0;
NET_API_STATUS nStatus;
//
// All parameters are required.
//
if (argc != 5)
{
fwprintf(stderr, L"Usage: %s \\\\\\\\ServerName UserName OldPassword NewPassword\\n", argv[0]);
exit(1);
}
//
// Call the NetUserChangePassword function.
//
nStatus = NetUserChangePassword(argv[1], argv[2], argv[3], argv[4]);
//
// If the call succeeds, inform the user.
//
if (nStatus == NERR_Success)
fwprintf(stderr, L"User password has been changed successfully\\n");
//
// Otherwise, print the system error.
//
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
NetUserSetInfo
NetUserGetInfo
Send comments about this topic to Microsoft
Build date: 8/13/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa370650(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:17:46