I want to query my directory for all User objects that don't contain a value for a given attribute... I have kind of hacked it up looking for things without a specific value (the potential assigned values are small, so this mostly worked) - but I would really like to know if there is a way to actually query for the absence of an attribute... kind of analogous to a relational database null.
Here is the query I ended up using:
(&(objectClass=User)(!extensionAttribute1=A))
Any ideas how to write an LDAP query looking for objects where an attribute has not been defined? Is this even possible?
To create an LDAP queryBrowse the Directory manager tree and select an object in the LDAP directory. The query that you're creating will return results from this point in the tree down. Click the New LDAP query toolbar button. Type a descriptive name for the query.
You can see the LDAP attribute name in the attribute editor. When working with scripts or creating a program you will need to use the LDAP attribute name. This page provides a visual reference of the LDAP field mappings in Active Directory.
LDAP# Attribute has an attributeTypes, which contains the name of that attribute (which links it to an Attribute Type) and an optional set of Attribute Options, and a collection of one or more values. A LDAP Entry contains a collection of Attributes.
We need a few more parens when doing this:
(&(objectClass=User)(!(extensionAttribute1=*)))
If you want to look for a particular attribute you need to remove some parens (removing the ! is not enough)
(&(objectClass=User)(extensionAttribute1=*))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With