-
Apr 21st, 2006, 09:37 AM
#1
Thread Starter
Fanatic Member
Problem sorting/grouping on objectclass property of AD search results
Hello again,
I *have* searched for answer on this but couldn't find anything so apologies if I'm covering old ground.
I have the following code to enumerate all objects in an OU
Public Sub GetOus(ByVal strDomainName As String)
Dim deEntry2 As New DirectoryEntry("LDAP://" & strDomainName.ToString())
Dim DSearch As New DirectorySearcher(deEntry2)
With DSearch
.SearchScope = SearchScope.OneLevel
.PropertiesToLoad.Add("name")
.PropertiesToLoad.Add("objectclass")
.PropertiesToLoad.Add("DistinguishedName")
.Sort.PropertyName = "name"
'.Filter = "objectclass=organizationalUnit"
'.Sort.Direction = SortDirection.Descending
End With
End Sub
Now, it works fine but there are, obviously, some OUs that contain sub-OUs as well as computer/user objects. I would like to be able to sort the results so that the objects that are OUs are at the top and any that are computers/users are after it. I'm sure I can do it using the objectclass parameter but I'm struggling to figure out the exact syntax.
-
Apr 21st, 2006, 11:14 AM
#2
Fanatic Member
Re: Problem sorting/grouping on objectclass property of AD search results
If my memory serves me correctly, you have to query each one separately. There is no built-in functionality to do this.
If you are wanting to load all OUs and the sub-objects of all of those OUs, then you are going to create a function to load a single OU and then call that recursively.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|