Core\Ldap\Ad\AccountFlags::isTrustedToAuthenticateForDelegation
$accountFlags->isTrustedToAuthenticateForDelegation(): boolChecks if a service on this account may act for a user without that user's password. The result is true or false.
Delegation lets a service connect to another service in the name of a user. With this flag, the service may do that even when the user did not log in with Kerberos, for example through a web form. An administrator also chooses which services it may connect to.
isTrustedToAuthenticateForDelegation reads the bit 0x1000000 of userAccountControl. A normal account with this flag is 16777728.
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"]A person is not a service
<?nvs// Shows that `isTrustedToAuthenticateForDelegation` returns `false` for the account of a person.// 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 `acts without password: false`. echo 'acts without password: ', $flags->isTrustedToAuthenticateForDelegation() ? 'true' : 'false', "\n";}acts without password: falseCount services with this right
<?nvs// Shows how to count the accounts that may act for a user without the user's password.// 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'] },);
uint $count = 0;uint $all = 0;foreach ($found as Core\Ldap\Entry $account) { var $flags = $account->accountFlags(); if ($flags != null) { $all = $all + 1; if ($flags->isTrustedToAuthenticateForDelegation()) { $count = $count + 1; } }}
// No account in this directory has this right. This prints `0 of 5`.echo $count, ' of ', $all, "\n";0 of 5Set the flag on a copy
<?nvs// Shows how `isTrustedToAuthenticateForDelegation` 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({ trustedToAuthenticateForDelegation: true });
// This prints `512 false` and then `16777728 true`. echo $flags->bits(), $flags->isTrustedToAuthenticateForDelegation() ? ' true' : ' false', "\n"; echo $changed->bits(), $changed->isTrustedToAuthenticateForDelegation() ? ' true' : ' false', "\n";}512 false16777728 true