Microsoft KB Archive/321029

= INFO: DsIsNTDSOnline Does Not Return Quickly as Expected =

Article ID: 321029

Article Last Modified on 2/8/2007

-

APPLIES TO


 * Microsoft Windows 2000 Service Pack 1
 * Microsoft Windows 2000 Service Pack 2
 * Microsoft Windows XP Professional

-



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
  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
 * 1) include 
 * 2) include 
 * 3) include 


 * 1) 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, &quot;%s&quot;, &quot;MYCOMPUTER&quot;);

printf(&quot;Checking machine: %s\n&quot;, targetName);

printf(&quot;Before\n&quot;); /*-    * Check if the AD is online *-*/    hr = DsIsNTDSOnline(targetName, &status);

if (hr != ERROR_SUCCESS) printf(&quot;DsIsNTDSOnline failed\n&quot;); else printf(&quot;After\n&quot;);

}                    Add IPX/SPX Protocol in your network protocol. Run the application that you built in step 1.

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

