The NetServerEnum function lists all servers of the specified type that are visible in the specified domain. For example, an application can call NetServerEnum to list all domain controllers only or all SQL servers only.
You can combine bit masks to list several types. For example, a value of 0x00000003 combines the bit masks for SV_TYPE_WORKSTATION (0x00000001) and SV_TYPE_SERVER (0x00000002).
Note If you require more information on the type, name, and comment for a specific server, use the WNetEnumResource function.
Security Requirements
No special group membership is required to successfully execute NetServerEnum.
NET_API_STATUS NetServerEnum(
LPTSTR servername, | |
DWORD level, | |
LPBYTE *bufptr, | |
DWORD prefmaxlen, | |
LPDWORD entriesread, | |
LPDWORD totalentries, | |
DWORD servertype, | |
LPTSTR domain, | |
LPDWORD resume_handle | |
); |
Parameters
servername
Pointer to a Unicode string containing the name of the remote server on which the function is to execute. A NULL pointer or string specifies the local computer.
level
Specifies one of the following values to return the level of information provided.
Value | Meaning |
100 | The bufptr parameter points to an array of SERVER_INFO_100 structures. |
101 | The bufptr parameter points to an array of SERVER_INFO_101 structures. |
bufptr
Pointer to the buffer in which the data set with the level parameter is stored.
prefmaxlen
Preferred maximum length, in 8-bit bytes of returned data.
entriesread
On return, the actual enumerated element count is located in the doubleword pointed to by entriesread.
totalentries
Returns the total number of visible servers and workstations on the network.
servertype
A DWORD mask that filters server entries to return from the enumeration. The defined mask bits specify:
Symbolic constant | Value | Meaning |
SV_TYPE_WORKSTATION | 0x00000001 | All LAN Manager workstations |
SV_TYPE_SERVER | 0x00000002 | All LAN Manager servers |
SV_TYPE_SQLSERVER | 0x00000004 | Any server running with Microsoft SQL Server |
SV_TYPE_DOMAIN_CTRL | 0x00000008 | Primary domain controller |
SV_TYPE_DOMAIN_BAKCTRL | 0x00000010 | Backup domain controller |
SV_TYPE_TIMESOURCE | 0x00000020 | Server running the Timesource service |
SV_TYPE_AFP | 0x00000040 | Apple File Protocol servers |
SV_TYPE_NOVELL | 0x00000080 | Novell servers |
SV_TYPE_DOMAIN_MEMBER | 0x00000100 | LAN Manager 2.x Domain Member |
SV_TYPE_LOCAL_LIST_ONLY | 0x40000000 | Servers maintained by the browser. See the following Remarks section. |
SV_TYPE_PRINT | 0x00000200 | Server sharing print queue |
SV_TYPE_DIALIN | 0x00000400 | Server running dial-in service |
SV_TYPE_XENIX_SERVER | 0x00000800 | Xenix server |
SV_TYPE_MFPN | 0x00004000 | Microsoft File and Print for Netware |
SV_TYPE_NT | 0x00001000 | Windows NT (either Workstation or Server) |
SV_TYPE_WFW | 0x00002000 | Server running Windows for Workgroups |
SV_TYPE_SERVER_NT | 0x00008000 | Windows NT Non-DC server |
SV_TYPE_POTENTIAL_BROWSER | 0x00010000 | Server that can run the Browser service |
SV_TYPE_BACKUP_BROWSER | 0x00020000 | Server running a Browser service as backup |
SV_TYPE_MASTER_BROWSER | 0x00040000 | Server running the master Browser service |
SV_TYPE_DOMAIN_MASTER | 0x00080000 | Server running the domain master Browser |
SV_TYPE_DOMAIN_ENUM | 0x80000000 | Primary Domain |
SV_TYPE_WINDOWS | 0x00400000 | Windows 95 or later |
SV_TYPE_ALL | 0xFFFFFFFF | All servers |
domain
A pointer to a Unicode string containing the name of the domain for which a list of servers is to returned. If NULL is specified, the primary domain is implied.
resume_handle
Reserved. Must be set to zero. Use the Wnet functions.
Return Values
If the function returns account information, the return value is NERR_Success.
If the function fails, the return value is one of the following error codes:
Value | Meaning |
ERROR_ACCESS_DENIED | The user does not have access to the requested information. |
NERR_InvalidComputer | The computer name is invalid. |
ERROR_NO_BROWSER_SERVERS_FOUND | No browser servers found. |
ERROR_MORE_DATA | More entries are available with subsequent calls. |
Remarks
The SV_TYPE_LOCAL_LIST_ONLY flag returns the list of servers maintained by the browser internally. This has meaning only on the master browser (or on a computer that has been the master browser in the past). The master browser is the machine that currently has rights to determine which machines can be servers or workstations on the net.
See Also
NetServerDiskEnum, NetQueryDisplayInformation, SERVER_INFO_100, SERVER_INFO_101