Core\Ldap\Ad::enabled
Core\Ldap\Ad::enabled(): Core\Ldap\FilterReturns a filter that matches the entries whose account is not disabled. Use it with search, to find the users who can still log in.
The filter tests the bit with the value 2 in userAccountControl. It matches when that bit is not set.
Good to know: an entry with no userAccountControl, such as a group, also matches. Combine the filter with Filter::equals('objectClass', 'user') to find only users.
Return value
Returns Core\Ldap\Filter. A Core\Ldap\Filter. An entry with no userAccountControl, such as a group, also matches. Combine it with a filter on objectClass to find only users.
Examples
The filter
<?nvs// Shows the text of the filter for accounts that are not disabled.
// This prints (!(userAccountControl:1.2.840.113556.1.4.803:=2)).echo Core\Ldap\Ad::enabled()->toString(), "\n";(!(userAccountControl:1.2.840.113556.1.4.803:=2))Only users
<?nvs// Shows how to match only the users whose account is not disabled.
// Without the `objectClass` test, groups would match too.var $active = Core\Ldap\Filter::all( Core\Ldap\Filter::equals('objectClass', 'user'), Core\Ldap\Ad::enabled(),);echo $active->toString(), "\n";(&(objectClass=user)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))Active staff
<?nvs// Shows how to match the users of a group whose account is not disabled.
var $staff = Core\Ldap\Dn::parse('CN=Staff,OU=Groups,DC=example,DC=test');var $filter = Core\Ldap\Filter::all( Core\Ldap\Filter::equals('objectClass', 'user'), Core\Ldap\Ad::memberOf($staff), Core\Ldap\Ad::enabled(),);echo $filter->toString(), "\n";(&(objectClass=user)(memberOf=CN=Staff,OU=Groups,DC=example,DC=test)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))