I am trying to do a LDAP Search however I keep getting the following error:
Unhandled Exception: System.Runtime.InteropServices.COMException (0x80072024): T
he administrative limit for this request was exceeded.
at System.DirectoryServices.SearchResultCollection.ResultsEnumerator.MoveNext
()
at System.DirectoryServices.DirectorySearcher.FindOne()
Here is the code: (The error is thrown at FindOne())
DirectoryEntry dirEntry = new DirectoryEntry("LDAP://myldap.com:1701/ou=People,o=My Company,c=CA", "", "", AuthenticationTypes.Anonymous);
DirectorySearcher dirSearcher = new DirectorySearcher(dirEntry);
string filter = "mail";
string filterValue = "[email protected]";
dirSearcher.Filter = string.Format("({0}={1})", filter, filterValue);
SortOption sortOption = new SortOption(filter, SortDirection.Ascending);
dirSearcher.Sort = sortOption;
dirSearcher.PropertiesToLoad.Add("uid");
dirSearcher.SearchScope = SearchScope.Subtree;
SearchResult result = dirSearcher.FindOne();
DirectoryEntry directEntry = result.GetDirectoryEntry();
Console.WriteLine("Result: {0}", directEntry.Properties["uid"].Value.ToString());
Any ideas how to get around this?