Core\Ldap\Ad\AccountFlags::isPreauthNotRequired
$accountFlags->isPreauthNotRequired(): boolChecks if Kerberos gives a ticket for this account without first checking the password. The result is true or false.
Kerberos is the system that Windows uses to log users in. Normally it checks that the user knows the password before it sends a ticket. When this flag is set, anybody can get a ticket for the account. An attacker can then try to guess the password from the ticket, without contacting the server again. Keep this flag off unless an old program needs it.
isPreauthNotRequired reads the bit 0x400000 of userAccountControl. A normal account with this flag is 4194816.
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 with a password check
<?nvs// Shows that `isPreauthNotRequired` returns `false` for an account where Kerberos checks the password.// 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 `no preauth: false`. echo 'no preauth: ', $flags->isPreauthNotRequired() ? 'true' : 'false', "\n";}no preauth: falseCount accounts without a check
<?nvs// Shows how to count the accounts that get a ticket without a password check.// A security check does this, because these passwords are easier to guess.// 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->isPreauthNotRequired()) { $count = $count + 1; } }}
// No account in this directory has this flag. This prints `0 of 5`.echo $count, ' of ', $all, "\n";0 of 5Set the flag on a copy
<?nvs// Shows how `isPreauthNotRequired` 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({ noPreauthRequired: true });
// This prints `512 false` and then `4194816 true`. echo $flags->bits(), $flags->isPreauthNotRequired() ? ' true' : ' false', "\n"; echo $changed->bits(), $changed->isPreauthNotRequired() ? ' true' : ' false', "\n";}512 false4194816 true