网站首页  词典首页

请输入您要查询的函数:

 

术语 netquerydisplayinformation
释义 NetQueryDisplayInformation
语法:
C++
NET_API_STATUS NetQueryDisplayInformation(
__in LPCWSTR ServerName,
__in DWORD Level,
__in DWORD Index,
__in DWORD EntriesRequested,
__in DWORD PreferredMaximumLength,
__out LPDWORD ReturnedEntryCount,
__out PVOID *SortedBuffer
);
NetQueryDisplayInformation功能
该NetQueryDisplayInformation函数返回用户帐户,计算机或组帐户信息。调用此功能快速枚举在用户界面显示帐户信息。
参数
服务器名 [in]
指针常量字符串指定的DNS或NetBIOS的远程服务器上的功能是执行的名称。如果该参数为NULL,则使用本地计算机。
Level [in]
指定的数据信息的Level。此参数可以是下列值之一。
ValueMeaning
1Return用户帐户信息。在SortedBuffer参数指向一个NET_DISPLAY_USER结构的数组。
2Return个人计算机的信息。在SortedBuffer参数指向一个NET_DISPLAY_MACHINE结构的数组。
3Return组帐户信息。在SortedBuffer参数指向一个NET_DISPLAY_GROUP结构的数组。
指数 [in]
指定第一入境的检索资料的索引。零到指定帐户信息检索与显示信息的第一项开始。有关详细信息,请参阅下面的备注部分。
EntriesRequested [in]
指定的项用来检索信息的最大数量。在Windows 2000和以后,每个NetQueryDisplayInformation调用返回一个对象的最大为100。
PreferredMaximumLength [in]
指定首选的最大大小,以字节为单位,系统分配的SortedBuffer参数返回的缓冲区。我们建议您将此参数设置为MAX_PREFERRED_LENGTH。
ReturnedEntryCount [out]
指针的值,它接收中的条目在SortedBuffer参数中返回缓冲区中。如果此参数为0,有一个项目为指标,没有大的作为指明。参赛作品时,可能会返回函数的返回值是NERR_Success或ERROR_MORE_DATA。
SortedBuffer [out]
缓冲区指针,它接收一个指向系统分配的缓冲区,它指定所要求的资料排序的列表。这些数据的格式取决于该级别的参数值。由于此缓冲区是由系统分配的,它必须释放使用NetApiBufferFree功能。请注意,您必须释放缓冲区,即使函数ERROR_MORE_DATA失败。有关详细信息,请参阅下面的返回值部分,主题网络管理功能,缓冲器和网络管理功能缓冲区长度。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值是下面的错误代码之一。
返回codeDescription
ERROR_ACCESS_DENIEDThe用户没有获得所需的信息。
ERROR_INVALID_LEVELThe级别参数指定一个无效的值。
ERROR_MORE_DATAMore项可用。也就是说,在最后一项SortedBuffer参数返回的不是最后进入可用。要检索其他条目,请NetQueryDisplayInformation设置为在中SortedBuffer最后一项next_index成员返回的参数值索引了。请注意,您不应该使用为任何目的next_index成员的值来检索,除非以NetQueryDisplayInformation其他调用更多的数据。
备注
如果您调用域控制器上运行Active Directory的这一功能,允许访问或拒绝的访问控制列表的安全对象(ACL)的基础。默认的ACL允许所有经过身份验证的用户和“前成员Windows2000兼容访问”组查看信息。如果您调用一个成员服务器或工作站,所有的身份验证的用户可以查看此功能的信息。有关匿名访问的信息,并限制在这些平台上匿名访问,看到了网络管理功能的安全要求。欲了解更多有关的ACL,ACE的,和访问令牌信息,请访问控制模型。
该NetQueryDisplayInformation函数只返回信息,而来电者具有读取权限。调用者必须具有名单到域对象的内容访问,并列举整个SAM域上的SAM服务器访问对象在系统容器中。
在NetQueryDisplayInformation和NetGetDisplayInformationIndex职能提供一个枚举用户和组帐户的有效机制。尽可能使用这些功能,而不是NetUserEnum函数或NetGroupEnum功能。
枚举成员的信任域或计算机帐户,请NetUserEnum,指定适当的过滤器的值,以获取您需要的帐户信息。枚举信任域,调用LsaEnumerateTrustedDomains或LsaEnumerateTrustedDomainsEx功能。
在此函数返回的条目数取决于在根域对象所在的安全描述符。该或者API将返回首100个参赛作品中域或整套的项,根据用户的访问权限。用于控制这种行为的ACE是“萨姆枚举,整个域”,并授予默认身份验证的用户。管理员可以修改此设置以允许用户枚举整个域。
每个NetQueryDisplayInformation调用返回一个对象的最大为100。函数调用NetQueryDisplayInformation枚举域帐户信息,可昂贵,在性能方面。如果您是Active Directory的程序,您可能能够使用IDirectorySearch接口的方法,使对域分页查询。有关更多信息,请参见IDirectorySearch::SetSearchPreference和IDirectorySearch::ExecuteSearch。枚举信任域,调用LsaEnumerateTrustedDomainsEx功能。
实例
下面的代码示例演示如何返回组帐户信息使用调用NetQueryDisplayInformation的功能。如果用户指定服务器名称,示例首先调用MultiByteToWideChar函数转换为Unicode名称。该范例调用NetQueryDisplayInformation,指定信息第3级(NET_DISPLAY_GROUP)检索组帐户信息。如果有项目的回报,样本返回数据并打印组信息。最后,代码示例释放的信息缓冲区分配的内存。
#define UNICODE
#include
#include
#include
#pragma comment(lib, "netapi32.lib")
void main( int argc, char *argv[ ] )
{
PNET_DISPLAY_GROUP pBuff, p;
DWORD res, dwRec, i = 0;
//
// You can pass a NULL or empty string
// to retrieve the local information.
//
TCHAR szServer[255]=TEXT("");
if(argc > 1)
//
// Check to see if a server name was passed;
// if so, convert it to Unicode.
//
MultiByteToWideChar(CP_ACP, 0, argv[1], -1, szServer, 255);
do // begin do
{
//
// Call the NetQueryDisplayInformation function;
// specify information level 3 (group account information).
//
res = NetQueryDisplayInformation(szServer, 3, i, 1000, MAX_PREFERRED_LENGTH, &dwRec, (PVOID*) &pBuff);
//
// If the call succeeds,
//
if((res==ERROR_SUCCESS) || (res==ERROR_MORE_DATA))
{
p = pBuff;
for(;dwRec>0;dwRec--)
{
//
// Print the retrieved group information.
//
printf("Name: %S\\n"
"Comment: %S\\n"
"Group ID: %u\\n"
"Attributes: %u\\n"
"--------------------------------\\n",
p->grpi3_name,
p->grpi3_comment,
p->grpi3_group_id,
p->grpi3_attributes);
//
// If there is more data, set the index.
//
i = p->grpi3_next_index;
p++;
}
//
// Free the allocated memory.
//
NetApiBufferFree(pBuff);
}
else
printf("Error: %u\\n", res);
//
// Continue while there is more data.
//
} while (res==ERROR_MORE_DATA); // end do
return;
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmaccess.h(包括Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
参见
网络管理概述
网络管理功能
获得功能
LsaEnumerateTrustedDomains
LsaEnumerateTrustedDomainsEx
NET_DISPLAY_GROUP
NET_DISPLAY_MACHINE
NET_DISPLAY_USER
NetGetDisplayInformationIndex
NetUserEnum
NetGroupEnum
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月13日
==英文原文==NetQueryDisplayInformation Function
The NetQueryDisplayInformation function returns user account, computer, or group account information. Call this function to quickly enumerate account information for display in user interfaces.
Syntax
C++
NET_API_STATUS NetQueryDisplayInformation(
__in LPCWSTR ServerName,
__in DWORD Level,
__in DWORD Index,
__in DWORD EntriesRequested,
__in DWORD PreferredMaximumLength,
__out LPDWORD ReturnedEntryCount,
__out PVOID *SortedBuffer
);
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.
Level [in]
Specifies the information level of the data. This parameter can be one of the following values.
ValueMeaning
1Return user account information. The SortedBuffer parameter points to an array of NET_DISPLAY_USER structures.
2Return individual computer information. The SortedBuffer parameter points to an array of NET_DISPLAY_MACHINE structures.
3Return group account information. The SortedBuffer parameter points to an array of NET_DISPLAY_GROUP structures.

Index [in]
Specifies the index of the first entry for which to retrieve information. Specify zero to retrieve account information beginning with the first display information entry. For more information, see the following Remarks section.
EntriesRequested [in]
Specifies the maximum number of entries for which to retrieve information. On Windows2000 and later, each call to NetQueryDisplayInformation returns a maximum of 100 objects.
PreferredMaximumLength [in]
Specifies the preferred maximum size, in bytes, of the system-allocated buffer returned in the SortedBuffer parameter. It is recommended that you set this parameter to MAX_PREFERRED_LENGTH.
ReturnedEntryCount [out]
Pointer to a value that receives the number of entries in the buffer returned in the SortedBuffer parameter. If this parameter is zero, there are no entries with an index as large as that specified. Entries may be returned when the function's return value is either NERR_Success or ERROR_MORE_DATA.
SortedBuffer [out]
Pointer to a buffer that receives a pointer to a system-allocated buffer that specifies a sorted list of the requested information. The format of this data depends on the value of the Level parameter. Because this buffer is allocated by the system, it must be freed using the NetApiBufferFree function. Note that you must free the buffer even if the function fails with ERROR_MORE_DATA. For more information, see the following Return Values section, and the topics 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 is one of the following error codes.
Return codeDescription
ERROR_ACCESS_DENIEDThe user does not have access to the requested information.
ERROR_INVALID_LEVELThe Level parameter specifies an invalid value.
ERROR_MORE_DATAMore entries are available. That is, the last entry returned in the SortedBuffer parameter is not the last entry available. To retrieve additional entries, call NetQueryDisplayInformation again with the Index parameter set to the value returned in the next_index member of the last entry in SortedBuffer. Note that you should not use the value of the next_index member for any purpose except to retrieve more data with additional calls to NetQueryDisplayInformation.

Remarks
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 NetQueryDisplayInformation function only returns information to which the caller has Read access. The caller must have List Contents access to the Domain object, and Enumerate Entire SAM Domain access on the SAM Server object located in the System container.
The NetQueryDisplayInformation and NetGetDisplayInformationIndex functions provide an efficient mechanism for enumerating user and group accounts. When possible, use these functions instead of the NetUserEnum function or the NetGroupEnum function.
To enumerate trusting domains or member computer accounts, call NetUserEnum , specifying the appropriate filter value to obtain the account information you require. To enumerate trusted domains, call the LsaEnumerateTrustedDomains or LsaEnumerateTrustedDomainsEx function.
The number of entries returned by this function depends on the security descriptor located on the root domain object. The API will return either the first 100 entries or the entire set of entries in the domain, depending on the access privileges of the user. The ACE used to control this behavior is "SAM-Enumerate-Entire-Domain", and is granted to Authenticated Users by default. Administrators can modify this setting to allow users to enumerate the entire domain.
Each call to NetQueryDisplayInformation returns a maximum of 100 objects. Calling the NetQueryDisplayInformation function to enumerate domain account information can be costly in terms of performance. If you are programming for Active Directory, you may be able to use methods on the IDirectorySearch interface to make paged queries against the domain. For more information, see IDirectorySearch::SetSearchPreference and IDirectorySearch::ExecuteSearch . To enumerate trusted domains, call the LsaEnumerateTrustedDomainsEx function.
Examples
The following code sample demonstrates how to return group account information using a call to the NetQueryDisplayInformation function. If the user specifies a server name, the sample first calls the MultiByteToWideChar function to convert the name to Unicode. The sample calls NetQueryDisplayInformation, specifying information level 3 ( NET_DISPLAY_GROUP ) to retrieve group account information. If there are entries to return, the sample returns the data and prints the group information. Finally, the code sample frees the memory allocated for the information buffer.
#define UNICODE
#include
#include
#include
#pragma comment(lib, "netapi32.lib")
void main( int argc, char *argv[ ] )
{
PNET_DISPLAY_GROUP pBuff, p;
DWORD res, dwRec, i = 0;
//
// You can pass a NULL or empty string
// to retrieve the local information.
//
TCHAR szServer[255]=TEXT("");
if(argc > 1)
//
// Check to see if a server name was passed;
// if so, convert it to Unicode.
//
MultiByteToWideChar(CP_ACP, 0, argv[1], -1, szServer, 255);
do // begin do
{
//
// Call the NetQueryDisplayInformation function;
// specify information level 3 (group account information).
//
res = NetQueryDisplayInformation(szServer, 3, i, 1000, MAX_PREFERRED_LENGTH, &dwRec, (PVOID*) &pBuff);
//
// If the call succeeds,
//
if((res==ERROR_SUCCESS) || (res==ERROR_MORE_DATA))
{
p = pBuff;
for(;dwRec>0;dwRec--)
{
//
// Print the retrieved group information.
//
printf("Name: %S\\n"
"Comment: %S\\n"
"Group ID: %u\\n"
"Attributes: %u\\n"
"--------------------------------\\n",
p->grpi3_name,
p->grpi3_comment,
p->grpi3_group_id,
p->grpi3_attributes);
//
// If there is more data, set the index.
//
i = p->grpi3_next_index;
p++;
}
//
// Free the allocated memory.
//
NetApiBufferFree(pBuff);
}
else
printf("Error: %u\\n", res);
//
// Continue while there is more data.
//
} while (res==ERROR_MORE_DATA); // end do
return;
}
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
Get Functions
LsaEnumerateTrustedDomains
LsaEnumerateTrustedDomainsEx
NET_DISPLAY_GROUP
NET_DISPLAY_MACHINE
NET_DISPLAY_USER
NetGetDisplayInformationIndex
NetUserEnum
NetGroupEnum
Send comments about this topic to Microsoft
Build date: 8/13/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa370610(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:22