I am connecting to LDAP and i am getting only classobject of type user, and i want only to get the Distinguished Name, when i dont do any sorting, (I comment the line of sorting) the results are coming just fine, the number of users are 13. and i can print them all, but they are not brought in Ascending order, so i did the sort based on the distinguishedName, when i add these lines to the code, it give me an empty collection of searchResults.
I DONT KNOW WHY, why when i do sorting, the data goes, and when i stop the sorting the data is there. whats wrong with the sorting???
DirectoryEntry entry = new DirectoryEntry(_path, username,
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = ("(objectClass=user)");
SortOption option = new SortOption("distinguishedName", System.DirectoryServices.SortDirection.Ascending);
mySearcher.Sort = option;
DataSet ds = new DataSet();
DataTable dtUsers = new DataTable("Users");
dtUsers.Columns.Add("distinguishedName");
SearchResultCollection ss = mySearcher.FindAll();
SearchResult a = ss[0];