system.directoryservices.dll!System.DirectoryServices.DirectoryEntry::Bind(b
ool throwIfFail = true) + 0x24d Bytes
system.directoryservices.dll!System.DirectoryServices.DirectoryEntry::Bind()
+ 0x14 Bytes
system.directoryservices.dll!System.DirectoryServices.DirectoryEntry::get_Ad
sObject() + 0xf Bytes
system.directoryservices.dll!System.DirectoryServices.DirectorySearcher::Fin
dAll(bool findMoreThanOne = true) + 0x186 Bytes
system.directoryservices.dll!System.DirectoryServices.DirectorySearcher::Fin
dAll() + 0x15 Bytes
SearchTimeout.exe!SearchTimeout.TEST.Main(string[] args = {Length=0}) Line
10 + 0xa Bytes C#
How do you think about above? It's a dump of call stack. It says that
DirectoryEntry class has at least two private methods named Bind().
You can use the ClientTimeout on the DirectorySearcher object instead.
Okay. Look at this code.
-------------------------------------------------------------------
using System;
using System.DirectoryServices;
class TEST
{
[STAThread]
static void Main(string[] args)
{
DirectoryEntry deRoot = new DirectoryEntry();
DirectorySearcher dsSearcher = new DirectorySearcher();
deRoot.Path= "LDAP://1.1.1.1/cn=Users,dc=mycom,dc=net";
deRoot.AuthenticationType = AuthenticationTypes.ServerBind;
dsSearcher.SearchRoot= deRoot;
dsSearcher.ClientTimeout = TimeSpan.FromSeconds(2);
dsSearcher.FindAll();
}
}
-------------------------------------------------------------------
Is it you said?
At this code, Server IP Address(1.1.1.1) is not exist in the network.
If you try this code, then you can see above call stack easily.
I Would like to specify the time needed to find out [Server Down]. The
sample code spends 20 seconds.
I mentioned about my own DirectoryServices namespace, at the first of my
question history.
It was written with Managed C++, wrapping Win32 LDAP API.
It is the purpose of my own DirectoryServices, that CONNECTION TIMEOUT and
PAGED SEARCH RESULTS HANDLING.
And, I hope to code using System.DirectoryServices can use my own
DirectoryServices without any modification.
So, I decided to make my own DirectoryServices to use same base class and
same interfaces.
According to RFC 2251 "Lightweight Directory Access Protocol (v3)",
connection timeout is not mentioned.
Maybe System.DirectoryServices based on it. And Win32 LDAP API may not
support it, too(I didn't check it, yet).
When I making it, I faced a proplem. DirectorySearcher.FindAll() returns
SearchResultCollection.
It was the start point of my question. Howto generating search results(as
SearchResultCollection) without any public constructors or related methods.
SearchResultCollection doesn't have Add() method.
And now, Marc Scheuner's answer encouraged me. I will check protected
constructor and Win32 LDAP API. But, it's not right now.
thank you, anyway.