网站首页  词典首页

请输入您要查询的函数:

 

术语 netusersetgroups
释义 NetUserSetGroups
语法:
C++
NET_API_STATUS NetUserSetGroups(
__in LPCWSTR servername,
__in LPCWSTR username,
__in DWORD level,
__in LPBYTE buf,
__in DWORD num_entries
);
NetUserSetGroups功能
该NetUserSetGroups函数设置为指定的用户帐户全局组成员身份。
参数
服务器名 [in]
一个常量字符串,它指定的DNS或NetBIOS的远程服务器上的功能是执行名称的指针。如果该参数为NULL,则使用本地计算机。
用户名 [in]
一个字符串常量,指定的用户为其设置全局组成员名字的指针。有关详细信息,请参见备注部分。
Level [in]
数据的信息化Level。此参数可以是下列值之一。
ValueMeaning
0The buf参数指向一个GROUP_USERS_INFO_0结构,指定全局组名的数组。
1The buf参数指向一个指定的属性全局组名GROUP_USERS_INFO_1结构的数组。
缓冲带 [in]
一个指定的缓冲区中的数据指针。有关更多信息,请参阅网络管理功能的缓冲器。
num_entries [in]
在数组中所包含的条目数指向的buf参数。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值可以是下面的错误代码之一。
返回codeDescription
ERROR_ACCESS_DENIEDThe用户没有获得所需的信息。
ERROR_INVALID_LEVELThe系统调用级别不正确。此错误,则返回参数的Level,如果是作为一个价值1比0或其他指定。
ERROR_INVALID_PARAMETERA参数传递是无效的。返回此错误,如果num_entries参数是无效的。
ERROR_NOT_ENOUGH_MEMORYInsufficient记忆来完成操作。
NERR_InvalidComputerThe计算机名无效。
NERR_NotPrimaryThe操作只允许在该域的主域控制器。
NERR_GroupNotFoundThe组组名指定的在GROUP_USERS_INFO_0结构或GROUP_USERS_INFO_1结构grui1_name成员grui0_name指出的buf参数并不存在。
NERR_InternalErrorAn发生内部错误。
NERR_UserNotFoundThe用户名找不到。
备注
如果您是Active Directory的程序,您可以调用某些Active Directory服务接口(ADSI)的方法来达到同样的功能,您可以通过调用用户的网络管理功能。有关更多信息,请参阅IADsUser和IADsComputer。
如果您调用域控制器上运行Active Directory的这一功能,允许访问或拒绝的访问控制列表的安全对象(ACL)的基础。默认的ACL只允许域管理员和Account Operators调用此函数。在成员服务器或工作站,只有Administrators和Power Users可以调用这个函数。有关更多信息,请参阅的网络管理功能的安全要求。欲了解更多有关的ACL,ACE的,和访问令牌信息,请访问控制模型。
该用户对象的安全描述符用于执行此函数访问检查。
若要授予在一个现有的全局组成员的用户,您可以调用NetGroupAddUser功能。
用户帐户名称被限制为20个字符和组名称被限制为256个字符。此外,帐户名称不能终止的期间,他们不能包含逗号或以下打印字符:“,/,\\,[,]:,|,”,“+,=,,,?, *.名称也不能包括在1-31范围内,这些非打印字符。
实例
下面的代码示例演示如何设置用户帐户,以在NetUserSetGroups调用全局组成员身份的功能。填充的代码示例在GROUP_USERS_INFO_0结构,并呼吁grui0_name成员NetUserSetGroups,指定信息化Level0。
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib")
#include
#include
#include
int wmain(int argc, wchar_t *argv[])
{
DWORD dwLevel = 0;
GROUP_USERS_INFO_0 gi;
NET_API_STATUS nStatus;
if (argc != 4)
{
fwprintf(stderr, L"Usage: %s \\\\\\\\ServerName UserName GroupName\\n", argv[0]);
exit(1);
}
//
// Fill in the GROUP_USERS_INFO_0 structure member.
//
gi.grui0_name = argv[3];
//
// Call the NetUserSetGroups function; specify level 0.
//
nStatus = NetUserSetGroups(argv[1],
argv[2],
dwLevel,
(LPBYTE)&gi,
1);
//
// If the call succeeds, inform the user.
//
if (nStatus == NERR_Success)
fwprintf(stderr, L"Group membership has been successful for %s\\n", argv[2]);
//
// 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
参见
网络管理概述
网络管理功能
用户功能
NetUserGetGroups
NetGroupAddUser
GROUP_USERS_INFO_0
GROUP_USERS_INFO_1
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月13日
==英文原文==NetUserSetGroups Function
The NetUserSetGroups function sets global group memberships for a specified user account.
Syntax
C++
NET_API_STATUS NetUserSetGroups(
__in LPCWSTR servername,
__in LPCWSTR username,
__in DWORD level,
__in LPBYTE buf,
__in DWORD num_entries
);
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 for which to set global group memberships. For more information, see the Remarks section.
level [in]
The information level of the data. This parameter can be one of the following values.
ValueMeaning
0The buf parameter points to an array of GROUP_USERS_INFO_0 structures that specifies global group names.
1The buf parameter points to an array of GROUP_USERS_INFO_1 structures that specifies global group names with attributes.

buf [in]
A pointer to the buffer that specifies the data. For more information, see Network Management Function Buffers .
num_entries [in]
The number of entries contained in the array pointed to by the buf parameter.
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_LEVELThe system call level is not correct. This error is returned if the level parameter was specified as a value other than 0 or 1.
ERROR_INVALID_PARAMETERA parameter passed was not valid. This error is returned if the num_entries parameter was not valid.
ERROR_NOT_ENOUGH_MEMORYInsufficient memory was available to complete the operation.
NERR_InvalidComputerThe computer name is invalid.
NERR_NotPrimaryThe operation is allowed only on the primary domain controller of the domain.
NERR_GroupNotFoundThe group group name specified by the grui0_name in the GROUP_USERS_INFO_0 structure or grui1_name member in the GROUP_USERS_INFO_1 structure pointed to by the buf parameter does not exist.
NERR_InternalErrorAn internal error occurred.
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.
To grant a user membership in one existing global group, you can call the NetGroupAddUser 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 set global group memberships for a user account with a call to the NetUserSetGroups function. The code sample fills in the grui0_name member of the GROUP_USERS_INFO_0 structure and calls NetUserSetGroups, 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 = 0;
GROUP_USERS_INFO_0 gi;
NET_API_STATUS nStatus;
if (argc != 4)
{
fwprintf(stderr, L"Usage: %s \\\\\\\\ServerName UserName GroupName\\n", argv[0]);
exit(1);
}
//
// Fill in the GROUP_USERS_INFO_0 structure member.
//
gi.grui0_name = argv[3];
//
// Call the NetUserSetGroups function; specify level 0.
//
nStatus = NetUserSetGroups(argv[1],
argv[2],
dwLevel,
(LPBYTE)&gi,
1);
//
// If the call succeeds, inform the user.
//
if (nStatus == NERR_Success)
fwprintf(stderr, L"Group membership has been successful for %s\\n", argv[2]);
//
// 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
NetUserGetGroups
NetGroupAddUser
GROUP_USERS_INFO_0
GROUP_USERS_INFO_1
Send comments about this topic to Microsoft
Build date: 8/13/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa370658(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:26:41