Hi there,
I'm creating a little application that between other things will get the
logged user information and will do a AD query to get his distinguishedName
attribute but that query is taking too long (about 8 seconds).
The code for the C# method is as follow:
string[] propToLoad = new string[] { "distinguishedName" };
string filter = "(&(objectCategory=user)(sAMAccountName=" + accountName +
"))";
DirectorySearcher searcher = new DirectorySearcher( filter, propToLoad );
SearchResult sr = searcher.FindOne();
if ( sr != null )
{
return sr.GetDirectoryEntry().Properties[ "distinguishedName"
].Value.ToString();
}
return null;
where accountName is the logged user account name.
Any idea why that's happening?
Am I missing some initialization?
Thanks in advanced
Mr. Fornaris