Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

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
0
NorthernGuru
Asked:
NorthernGuru
  • 2
2 Solutions
 
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
 
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
 
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.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now