Hi,
I have an Active Directory that have an OU structure below.
Head Office
IT
Accounting
Finance
etc...
Where Head Office is the Root OU and the ones below are sub OUs.
This code works fine when I run it:
But it returns all the Users in all the sub OUs. What I only want is to return Users from certain sub OUs, e.g. IT.
How can I further filter the sub OUs, please help.
Thanks
Mike
I have an Active Directory that have an OU structure below.
Head Office
IT
Accounting
Finance
etc...
Where Head Office is the Root OU and the ones below are sub OUs.
This code works fine when I run it:
Code:
strBase = "<LDAP://ou=Head Office,dc=kuplax,dc=com>"
strFilter = "(&(objectCategory=person)(objectClass=user))"
strAttributes = "sAMAccountName,cn,userPrincipalName,"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
Set adoRecordset = adoCommand.Execute
But it returns all the Users in all the sub OUs. What I only want is to return Users from certain sub OUs, e.g. IT.
How can I further filter the sub OUs, please help.
Thanks
Mike