I am using a DirectorySearcher to return results from an LDAP query.
I got the code from the following book:
Professional C# 2nd Edition from Wrox
It works fine until I add in the line indicated below which is supposed to just sort my results. Then I get this error :
"The server does not support the requested critical extension"
using (DirectoryEntry de = new DirectoryEntry())
// Set credentials of an AD account to "Run As"
de.Username = XXXXXXXXXXXXXX;
de.Password = XXXXXXXXXXXXXX;
// Set active LDAP path
de.Path = LDAPpath;
using (DirectorySearcher searcher = new DirectorySearcher())
searcher.SearchRoot = de;
searcher.Filter = "(&(objectClass=user))";
searcher.SearchScope = SearchScope.Subtree;
/****The following line causes the error - if I remove this line it works, but unsorted ****/
searcher.Sort = new SortOption("distinguishedName", SortDirection.Ascending);
SearchResultCollection results = searcher.FindAll();
UserListRepeater.DataSource = results;