Core\Ldap\Filter::present
Core\Ldap\Filter::present(string $attribute): Core\Ldap\FilterCore\Ldap\Filter::present( string $attribute, ): Core\Ldap\Filter
Builds a filter that finds the directory entries that have any value for an attribute.
Use it to find every account that has a mail address, or, together with Core\Ldap\Filter::not, every account that has none. The value itself does not matter, only that the attribute is there.
A name with a character that an attribute name cannot have throws a LogicError.
Good to know: present("objectClass") matches every entry, because every entry has an object class. It is the usual filter when you want all entries below a place in the directory.
Parameters
$attributestringThe attribute's name, such assAMAccountName. It cannot betainted.
Return value
Returns Core\Ldap\Filter. A Core\Ldap\Filter.
Errors
LogicError$attributeis not an attribute name.
Examples
Accounts with a mail address
<?nvs// Shows how to find every entry that has a mail address.
var $filter = Core\Ldap\Filter::present('mail');// This prints (mail=*).echo $filter->toString(), "\n";(mail=*)Accounts without a mail address
<?nvs// Shows how to find the user accounts that have no mail address.
var $filter = Core\Ldap\Filter::all( Core\Ldap\Filter::equals('objectClass', 'user'), Core\Ldap\Filter::not(Core\Ldap\Filter::present('mail')),);// This prints (&(objectClass=user)(!(mail=*))).echo $filter->toString(), "\n";(&(objectClass=user)(!(mail=*)))Every entry
<?nvs// Shows the filter that matches every entry in a directory.
// Every entry has an `objectClass`, so this filter matches all of them.var $filter = Core\Ldap\Filter::present('objectClass');// This prints (objectClass=*).echo $filter->toString(), "\n";(objectClass=*)