INFO: DsIsNTDSOnline Does Not Return Quickly as Expected (321029)



The information in this article applies to:

  • Microsoft Windows 2000 Professional SP1
  • Microsoft Windows 2000 Professional SP2
  • Microsoft Windows XP Professional SP1

This article was previously published under Q321029

SUMMARY

If you call the DsIsNTDSOnline function under certain circumstances, the call may not return quickly, as expected. The time it takes for the call to DsIsNTDSOnline to return depends on the network protocols installed on the client.

MORE INFORMATION

By default, the Directory Service functions use remote procedure call (RPC), regardless of the underlying network protocol. Because the Active Directory relies heavily on TCP/IP, a call to the DsIsNTDSOnline function will return immediately, regardless of the status of the targeted computer.

However, in some networking environments, other protocols in addition to TCP/IP may be installed on the client. In this scenario, DsIsNTDSOnline tries each network protocol in its binding order. If the targeted computer is not reachable or is not available, the control is returned to the calling process after DsIsNTDSOnline has tried all network protocols. The length of the delay also differs from one network protocol to another.

Steps to Reproduce the Problem

  1. Replace MYCOMPUTER with the NetBIOS name of your computer as targetName in the following sample code. Note that you must link to Ntdsbcli.lib before you build the application.

    sample.c
    #include <windows.h>
    #include <stdio.h>
    #include <Ntdsbcli.h>
    
    #define MAX_LEN 100
    
    void main(void)
    {
        char targetName[MAX_LEN];
        BOOL status;
        HRESULT hr;
    
        /*---------------------------------------------------------
         * set the targetName to the NETBIOS name of your computer
         *---------------------------------------------------------*/ 
        sprintf(targetName, "%s", "MYCOMPUTER");
    
        printf("Checking machine: %s\n", targetName);
    
        printf("Before\n");
    	
        /*---------------------------------------------------------
         * Check if the AD is online
         *---------------------------------------------------------*/ 
        hr = DsIsNTDSOnline(targetName, &status);
    
        if  (hr != ERROR_SUCCESS) 
    	printf("DsIsNTDSOnline failed\n");
        else
    	printf("After\n");
    
    }
    					
  2. Add IPX/SPX Protocol in your network protocol.
  3. Run the application that you built in step 1.

    Notice that the length of time between the "Before" and "After" output is printed on the console.

REFERENCES

For more information about the DsIsNTDSOnline function, visit the following Microsoft Web site:

Modification Type:MinorLast Reviewed:3/19/2004
Keywords:kbDSWADSI2003Swept kbDSWADSI2003Swept kbinfo KB321029