JSI Tip 10619. How can I filter an Active Directory query by testing if a string attribute is empty (not entered)?

Jerold Schulman

June 28, 2006

1 Min Read
ITPro Today logo in a gray background | ITPro Today

When you compose an LDAP (Lightweight Directory Access Protocol) query, or a DSQUERY query, or an Adfind.exe query, you can filter your query based upon the values of attributes that you specify, like (postalCode=30004).

If you wanted to filter postalCode for being not entered, you would use (!postalCode=*), where ! is NOT EQUAL.

If you wanted to returned the distinguished name, city, state, and postal code of all users that have had no state and/or postal code entered, in CSV format, you could use:

adfind -default -nodn -csv -csvdelim ";" -nocsvheader -f "&(objectCategory=person)(objectClass=user)(|(!st=*)(!postalcode=*))" distinguishedName l st postalcode

NOTE: See How can I filter an Active Directory query by testing an attribute to be this OR that?

NOTE: See What operators can I use when filtering an Active Directory query?

NOTE: See How can I filter an Active Directory query using a bitwise flag?

NOTE: See ADFind.exe freeware can use :AND: and :OR: instead of :1.2.840.113556.1.4.803: and :1.2.840.113556.1.4.804: to define a bitwise filter.



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like