• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2132
  • Last Modified:

Active Directory Query for "Non-Disabled Computers"& Expanded Query by Partial Computer Name *lt*

I need to adjust my LDAP query so that I get only computers that are not disabled.

The query I use to return only disabled workstations is (&(objectCategory=computer)(userAccountControl:1.2.840.113556.1.4.803:=2))

I need the exact same query, but in reverse so I get only the "non-disabled" workstations.

I also need to expand the query so that I can specify a partial computer name and get all the non-disabled computers that have the partial name *lt*
0
ACECORP
Asked:
ACECORP
1 Solution
 
Mike KlineCommented:
(&(objectCategory=computer)(!userAccountControl:1.2.840.113556.1.4.803:=2)(name=*lt*))
Some comments,
This is not going to be an efficient query.  First because the ! is used (not).  Generally it is best to avoid those and the *text* string is also not efficient
http://msdn.microsoft.com/en-us/library/ms808539.aspx#efficientadapps_topic01kk
  • Avoid using the logical NOT operator
    Avoid using the logical NOT operator because the query processor returns objects that you do not have access to or specific attributes that do not have a value. The query processor considers those objects and attributes as satisfying the query.  

  • Do not perform medial searches on attributes without medial indices
    Place wildcards at the end of, rather than at the beginning of, the search string. For example, use cn=smi* instead of cn=*hill* or cn=*mith. The standard indexes that were introduced with Windows 2000 are only useful for substring or exact match queries. If you want to perform medial searches, then you need to create a medial index on the attribute that will be part of a filter. The creation of a medial index is described later in this document.
If you are only using this query once or twice you won't kill the performance of AD but if you are going to use it in some applications and doing it on a massive scale then you could run into issues.  You can also enable certain logging levels to help you identify those.  For more on field engineering logging see the recommendation here:
http://adisfun.blogspot.com/2009/04/lessons-learned-from-eric-fleischman.html
Thanks
Mike
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

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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