HOWTO: Enumerate MSCS Clusters in a DomainID: Q217203
|
This article provides sample code that demonstrates enumerating all Microsoft Cluster Server (MSCS) Clusters in a domain.
There is a reserved bit for clusters in the NetBios information for a server. The bit is set only if the server name is a Cluster Name resource. This does not apply to virtual server names. There is no direct way to enumerate virtual servers in a domain or to determine whether or not a given server is virtual. By calling NetServerEnum with the SV_TYPE_CLUSTER_NT flag, a list of all clusters in the specified domain is returned:
#include <windows.h>
#include <clusapi.h>
#include <lmcons.h>
#include <lmserver.h>
#include <lmapibuf.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
// Collect list of clusters from the network.
DWORD dwStatus;
DWORD nEntriesRead;
DWORD nTotalEntries;
DWORD iEntry;
SERVER_INFO_100 * pServerInfo = NULL;
SERVER_INFO_100 * pCurServerInfo;
dwStatus = NetServerEnum(
NULL, // servername
100, // level
(LPBYTE *) &pServerInfo,
4096, // prefmaxlen
&nEntriesRead, // entriesread
&nTotalEntries, // totalentries
SV_TYPE_CLUSTER_NT, // servertype
NULL, // domain
NULL // resume_handle
);
if( ERROR_SUCCESS == dwStatus && NULL != pServerInfo ){
wprintf( L"Clusters found in the domain: \n" );
pCurServerInfo = pServerInfo;
for (iEntry = 0 ; iEntry < nTotalEntries ; iEntry++, pCurServerInfo++){
wprintf( L"%s\n", pCurServerInfo->sv100_name );
}
NetApiBufferFree(pServerInfo);
}
else{
wprintf( L"No clusters were found in the domain.\n" );
}
return 0;
}
Additional query words:
Keywords : kbClustServ kbClustServ100 kbGrpPlatform kbDSupport
Version : winnt:4.0
Platform : winnt
Issue type : kbhowto
Last Reviewed: July 23, 1999