ADO Search by AD account description

Hi,

I'm trying to search for a number of AD computer accounts based on their description, but can't seem to get the query right.

"SELECT ADsPath, Description, Name FROM 'LDAP://" & strRootOUDN & strDomainDN & "' WHERE " & "objectClass='computer' AND description <> '" & strSubnet & "'"

Whatever I do to play around with the "AND description" part of the query returns either everything or nothing.  

The description field of our computer accounts contain the machines IP address, so I'm looking to return a set of records containing all computers whose description field begins with "192.168.1." (for example).

Does anybody know the correct query syntax for this?

Cheers

Andy
NorthernGuruAsked:
Who is Participating?
 
RimvisCommented:
Hi NorthernGuru,

Try this:
"SELECT ADsPath, Description, Name FROM 'LDAP://" & strRootOUDN & strDomainDN & "' WHERE objectClass='computer' AND description = '192.168.1.*'

Open in new window

0
 
MisterTwelveCommented:
On ADUC create a custom query and use

(&(objectCategory=computer)(objectClass=computer)(description=*))

change "*" for your description
0
 
NorthernGuruAuthor Commented:
Ah, sorry. I probably should have mentioned that I'm trying to do this via a query inside a vbscript.

How would this translate?

Cheers

Andy
0
 
NorthernGuruAuthor Commented:
Thanks Rimvis

This worked perfectly.  I have no idea why I didn't just try this in the first place.  I feel pretty stupid now !

Much appreciated.  Cheers !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.