Core\Ldap\Ad\AccountFlags::isNotDelegated
$accountFlags->isNotDelegated(): boolChecks if no service may act for this user. The result is true or false.
Delegation lets a service connect to another service in the name of a user. When this flag is set, no service may do that for this user, even a service that is trusted for delegation. Administrators set this flag on accounts with many rights, such as their own accounts.
isNotDelegated reads the bit 0x100000 of userAccountControl. A normal account with this flag is 1049088.
Return value
Returns bool. true when the bit is set, and false when it is not.
Changelog
| Version | Change |
|---|---|
0.0.6 | Every Core\Ldap\Ad\AccountFlags method that checks a flag now starts with is, has, allows or uses, for example isDisabled() and hasNonExpiringPassword(). The field trustedToAuthForDelegation of with() is now trustedToAuthenticateForDelegation. |
Examples
The examples below run with this configuration file.
# These examples use the LDAP directory server on this computer at port 16636.# `tls_ca_file` is the certificate that the server's certificate is checked against.[ldap.corp]url = "ldaps://127.0.0.1:16636"base = "DC=example,DC=test"user = "CN=Reader,OU=Company,DC=example,DC=test"password = "Novis-reader-1"tls_ca_file = "../../../../../tests/db/ca.crt"timeout = "5s"
# The program may open the `corp` directory.[capabilities.ldap]connect = ["corp"]An account a service may act for
<?nvs// Shows that `isNotDelegated` returns `false` for an account without this protection.// requires: samba-ad
var $corp = Core\Ldap::connect('corp');var $flags = $corp->read('CN=Anna Berg,OU=Company,DC=example,DC=test', { select: ['userAccountControl'] })?->accountFlags();
if ($flags != null) { // This prints `not delegated: false`. echo 'not delegated: ', $flags->isNotDelegated() ? 'true' : 'false', "\n";}not delegated: falseList accounts without protection
<?nvs// Shows how to list the accounts that a service may act for.// requires: samba-ad
var $corp = Core\Ldap::connect('corp');var $found = $corp->search( Core\Ldap\Filter::equals('objectClass', 'user'), { base: 'OU=Company,DC=example,DC=test', select: ['userAccountControl'] },);
array<tainted string> $names = [];foreach ($found as Core\Ldap\Entry $account) { var $flags = $account->accountFlags(); if ($flags != null && !$flags->isNotDelegated()) { $names[] = $account->dn()->rdnValue(); }}
// The server sends entries in no fixed order, so the names are sorted.// No account here has this flag. This prints `Anna Berg`, `Ben Kohl`, `Carla Diaz`, `Dora Lind` and `Reader`.foreach (Core\Arr::sort($names) as tainted string $name) { echo $name, "\n";}Anna BergBen KohlCarla DiazDora LindReaderProtect a copy
<?nvs// Shows how `isNotDelegated` and the number change on a copy made with `with`.// requires: samba-ad
var $corp = Core\Ldap::connect('corp');var $flags = $corp->read('CN=Anna Berg,OU=Company,DC=example,DC=test', { select: ['userAccountControl'] })?->accountFlags();
if ($flags != null) { var $changed = $flags->with({ notDelegated: true });
// This prints `512 false` and then `1049088 true`. echo $flags->bits(), $flags->isNotDelegated() ? ' true' : ' false', "\n"; echo $changed->bits(), $changed->isNotDelegated() ? ' true' : ' false', "\n";}512 false1049088 true