Core\Ldap\Filter::not
Core\Ldap\Filter::not(Core\Ldap\Filter $filter): Core\Ldap\FilterCore\Ldap\Filter::not( Core\Ldap\Filter $filter, ): Core\Ldap\Filter
Builds a filter that finds the directory entries that the given filter does not match.
Use it to leave something out, such as the accounts without a mail address, or the computers among all accounts. LDAP has no "greater than" and no "less than" filter, and not is how you write them: "not at most 5" means "greater than 5".
Good to know: an entry that has no value for the attribute is not matched by the inner filter, so not matches it. Filters can be put inside each other up to 100 levels deep, and one more level throws a LogicError.
Parameters
$filterCore\Ldap\FilterThe filter to reverse.
Return value
Returns Core\Ldap\Filter. A Core\Ldap\Filter.
Errors
LogicErrorThe new filter has more than 100 levels ofall,anyandnotinside each other.
Examples
Leave out computers
<?nvs// Shows how to leave the computer accounts out of a list of accounts.
// In Active Directory, a computer account is also a `user`.var $filter = Core\Ldap\Filter::all( Core\Ldap\Filter::equals('objectClass', 'user'), Core\Ldap\Filter::not(Core\Ldap\Filter::equals('objectClass', 'computer')),);// This prints (&(objectClass=user)(!(objectClass=computer))).echo $filter->toString(), "\n";(&(objectClass=user)(!(objectClass=computer)))None of these
<?nvs// Shows how to find the entries that match none of several filters.
var $filter = Core\Ldap\Filter::not(Core\Ldap\Filter::any( Core\Ldap\Filter::equals('l', 'Vienna'), Core\Ldap\Filter::equals('l', 'Graz'),));// This prints (!(|(l=Vienna)(l=Graz))).echo $filter->toString(), "\n";(!(|(l=Vienna)(l=Graz)))The nesting limit
<?nvs// Shows the limit on how deep filters can be put inside each other.
var $filter = Core\Ldap\Filter::present('mail');int $levels = 1;try { // Each `not` puts the filter one level deeper. while (true) { $filter = Core\Ldap\Filter::not($filter); $levels = $levels + 1; }} catch (LogicError $error) { // The 101st level throws an error. This prints 100. echo $levels, "\n";}100