Hi,
I am developing a SharePoint application which needs users from a specified Windows Server 2003 Active Directory Organizational Unit.
Firstly I wasn't concerned about the 'Dispose' and 'Close' operations on DirectoryServices objects. In this point the retrieve operations were quick and successful.
But this was causing 'Server is not operational' error after 2ish attempts. And this error makes the whole application operates worse like stopping other AD operations.
Then, I corrected this error by adding using statements on every DirectoryEntry, DirectorySearcher and SearchResultCollection objects.
Then I have reached a point that I have no longer get 'Server is not operational' error. But when I try to retrieve users from AD 1 or more times by using DirectorySearcher.FindAll method, the first one operates quick and successfully, others more slowly but successfully. It kinda takes the duration of a timeout. Could you please help me with my situation about this slow down?
Here is the sample code:
using (DirectoryEntry directoryEntry = new DirectoryEntry(connectionString, userName, password))
{
using (DirectorySearcher search = new DirectorySearcher(directoryEntry))
{
search.SearchScope = SearchLevel.OneLevel;
search.ReferralChasing = ReferralChasingOption.All;
search.Filter = filter;
search.SizeLimit = 200;
//Limits the property count for search result
SetUserDirectorySearcherPropertiesToLoad(search);
using (SearchResultCollection result = search.FindAll())
{
foreach (SearchResult searchResult in result)
{
// Get user attributes
}}}}
Thanks in advance