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

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.



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish