LDAP query for users and computers in "Domain Computers" group
I'm trying to build some LDAP query using PowerShell or C# to search for a certain user or computer in the "Domain Computers" predefined group.
I know that it is not a regular group.
It is possible to separate that query as follows:
For a computer in the "Domain Computers" group:
$strFilter = "(&(objectClass=computer)(primaryGroupID=515)(name=MyPC))"
For a user in the "Domain Users" group:
$strFilter = "(&(objectClass=user)(primaryGroupID=515)(name=MyUser))"
But I would like to find another query, due to some constrains.
Using Active Directory searcher, I was able to find the "Domain Computers" group under the "Users" OU with the following parameters:
distinguishedName = CN=Domain Computers,CN=Users,DC=MyDC,DC=local objectCategory = CN=Group,CN=Schema,CN=Configuration,DC=MyDC,DC=local objectClass = top ; group
I tried to build the query in the following syntax, with no success:
For query a computer:
$strFilter = "(&(objectCategory=group)(objectClass=computer)(name=MyPC)(CN=Domain computers,CN=Users,DC=supportlab,DC=lcoal))"
Any idea how can compose both queries for users and computers, using the above syntax?
链接地址: http://www.djcxy.com/p/60892.html