我有以下代码:
// Declare new DirectoryEntry and DirectorySearcher
DirectoryEntry domainRoot = new DirectoryEntry("LDAP://rootDSE");
string rootOfDomain = domainRoot.Properties["rootDomainNamingContext"].Value.ToString();
DirectorySearcher dsSearch = new DirectorySearcher(rootOfDomain);
// Set the properties of the DirectorySearcher
dsSearch.Filter = "(objectClass=Computer)";
dsSearch.PropertiesToLoad.Add("whenCreated");
dsSearch.PropertiesToLoad.Add("description");
dsSearch.PropertiesToLoad.Add("operatingSystem");
dsSearch.PropertiesToLoad.Add("name");
// Execute the search
SearchResultCollection computersFound = dsSearch.FindAll();
我想按whenCreated
属性按降序对结果进行排序,以便最新的计算机对象位于顶部。
我不能简单地做:
SortOption sortedResults = new SortOption("whenCreated", SortDirection.Descending);
dsSearch.Sort = sortedResults;
因为服务器返回错误(http://social.technet.microsoft.com/Forums/en-US/winserverDS/thread/183a8f2c-0cf7-4081-9110-4cf41b91dcbf/)
对此进行排序的最佳方法是什么?