Hi,Joe
I have read your book about the directory service programming, you have done a great job!
Howerver, there are still something make me confused:
I have a MOSS/Sharepoint running in a AD environment and using the AD authentication.
The MOSS is runing with a application pool under a public domain account.
In a MOSS page, i am using DirectoryEntry and DirectorySearcher to query AD server for users' information, and i write the code following the example code in chapter 3 of your book.
DirectoryEntry rootDSE = new DirectoryEntry( LDAP://myserver.mydomain.com/RootDSE" );
1 When users browse the page from different clients, should the default networkcredential be the public account that running my MOSS or every user's account from their clients?
2 You tell us to store a single DirectoryEntry object in a static variable or cache, do you mean that we should keep the single DirectoryEntry object for all requests from different clients and never dispose it unless we restart the iis service?
3 We have many AD servers, but how can we specify a different server for each request? Or is there any way to switch a server when the current server throw a exception such as "the server is not operational"?
Thanks again, you are a great man.
Additon
-----------------------------------------------------------------------------------------
My Web application is running as a domain account,and in my page code i wrote like this:
string server="xx.hd.com";
string account="myadmin";
string pwd="mypwd";
using(DirectoryEntry entryRoot=new DirectoryEntry(server,account,mypwd,AuthenticationType.Secure))
{
using(DirectoryEntry entry=new DirectoryEntry(server,account,mypwd,AuthenticationType.Secure)){
using (DirectorySearcher mySearcher= new DirectorySearcher(enrty))
{
mySearcher.SearchScope = SearchScope.Subtree;
mySearcher.Filter="(|(objectClass=user)(SAMAccountName=u00123456)(SAMAccountName=u00123457)(SAMAccountName=u00123458))";
SearchResultCollection results = mySearcher.FindAll();
foreach(SearchResult result in results)
{
//load result's properties
}
}
}
}
However, when i execute netstat command on my ad server , there is a tcp list like this:
tcp hd02:1023 hd01:ldap time_wait
tcp hd02:1024 hd01:ldap time_wait
tcp hd02:1025 hd01:ldap time_wait
tcp hd02:1026 hd01:ldap time_wait
tcp hd02:1027 hd01:ldap time_wait
....
hd02 is my web server, hd01 is my ad server
why there are still so many time_wait tcp connections on my ad server?