note 124058 added to function.ldap-modify-batch
| From: | shintoz.yahoo.com via php-notes | Date: | Mon, 22 Jul 2019 16:09:02 +0000 |
| Subject: | note 124058 added to function.ldap-modify-batch | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-211673@lists.php.net to get a copy of this message | ||
Example #6 Change a user's password (Active Directory) (Correction)
In a properly configured Active Directory Environment (i.e. you cannot have blank passwords), the
ldap_modify_batch example (#5) is incorrect and will fail with a constraint violation error.
The correct way to batch modify a user password for Active Directory (tested on a Windows 2012R2
Forest/Domain) would be:
<?php
function adifyPw($pw)
{
return iconv("UTF-8", "UTF-16LE", '"' . $pw .
'"');
}
$dn = "cn=Jack Smith-Jones,ou=Wizards,dc=ad,dc=example,dc=com";
$modifs = [
[
"attrib" => "unicodePwd",
"modtype" => LDAP_MODIFY_BATCH_REPLACE,
"values" => [adifyPw("correct horse battery staple")],
],
];
ldap_modify_batch($connection, $dn, $modifs);
?>
This is because a batch remove violates the "no blank passwords" constraint.
----
Server IP: 208.43.231.9
Probable Submitter: 82.199.157.54 (proxied: 138.69.160.1)
----
Manual Page -- http://php.net/manual/en/function.ldap-modify-batch.php
Edit -- https://master.php.net/note/edit/124058
Del: integrated -- https://master.php.net/note/delete/124058/integrated
Del: useless -- https://master.php.net/note/delete/124058/useless
Del: bad code -- https://master.php.net/note/delete/124058/bad+code
Del: spam -- https://master.php.net/note/delete/124058/spam
Del: non-english -- https://master.php.net/note/delete/124058/non-english
Del: in docs -- https://master.php.net/note/delete/124058/in+docs
Del: other reasons-- https://master.php.net/note/delete/124058
Reject -- https://master.php.net/note/reject/124058
Search -- https://master.php.net/manage/user-notes.php