Microsoft KB Archive/217203

{|
 * width="100%"|

HOWTO: Enumerate MSCS Clusters in a Domain

 * }

Q217203

-

The information in this article applies to:


 * Microsoft Windows NT Server version 4.0
 * Microsoft Windows NT Workstation version 4.0
 * Microsoft Cluster Server

-

SUMMARY
This article provides sample code that demonstrates enumerating all Microsoft Cluster Server (MSCS) Clusters in a domain.

MORE INFORMATION
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:

 In Microsoft Visual C++ 6.0, create a new Win32 Console Application. Choose An Empty Project on the dialog box that appears, and click Finish. From the Project menu, choose Settings. Click the Link tab of the Settings dialog box that appears. Add Clusapi.lib and Netapi32.lib to the list of .lib files in the Object/library Modules text box. Add a new C source file to the project.  Add the following code to the source file: #include 
 * 1) include 
 * 2) include 
 * 3) include <lmserver.h>
 * 4) include <lmapibuf.h>
 * 5) 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; } </li> Compile the project.</li> Run the project.</li></ol>

RESULT: The application will list all Cluster Servers on the current Windows NT domain.

Additional query words:

Keywords : kbClustServSearch kbClustServ100 kbGrpDSPlatform _IK

Issue type : kbhowto

Technology : kbWinNTsearch kbWinNTWsearch kbWinNTW400 kbWinNTW400search kbWinNT400xsearch kbWinNTSsearch kbWinNTS400xsearch kbWinNTS400 kbAudDeveloper kbClustServSearch