Req #64317 [Opn->Csd]: [PATCH] add ldap_modify_batch function
Edit report at https://bugs.php.net/bug.php?id=64317&edit=1
ID: 64317
User updated by: ondra dot hosek at gmail dot com
Reported by: ondra dot hosek at gmail dot com
Summary: [PATCH] add ldap_modify_batch function
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: LDAP related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Good point. I discussed this on the mailing list and forgot all about this bug. Closing.
Previous Comments:
------------------------------------------------------------------------
[2015-06-10 11:05:39] martin dot keckeis1 at gmail dot com
This was already added in PHP 5.4: http://php.net/manual/en/function.ldap-modify-batch.php
------------------------------------------------------------------------
[2013-02-27 23:35:04] ondra dot hosek at gmail dot com
Description:
------------
Hi,
motivated by the impossibility of performing an Active Directory password change (not reset), which
requires a simultaneous REMOVE and ADD operation on the unicodePwd attribute of a user, I have set
out to write a function named ldap_modify_batch that would allow this.
The test script demonstrates the API of this function. I'll admit that this API (especially the
array-of-arrays-of-arrays part) is a bit weird and I'll gladly accept tips on how to streamline
it. There is also a (more complete but also more contrived) example in the function body itself.
Test script:
---------------
<?php
function adifyPw($pw)
{
$quoted = '"' . $pw . '"';
$utf16d = iconv("UTF-8", "UTF-16LE", $quoted);
return $utf16d;
}
$curPwd = adifyPw("Tr0ub4dor&3");
$newPwd = adifyPw("correct horse battery staple");
$conn = ldap_connect("ldaps://dc.ad.example.com/");
ldap_bind($conn, "john@ad.example.com", "Tr0ub4dor&3");
$mods = array(
array(
"attrib" => "unicodePwd",
"modtype" => LDAP_MODIFY_BATCH_REMOVE,
"values" => array($curPwd)
),
array(
"attrib" => "unicodePwd",
"modtype" => LDAP_MODIFY_BATCH_ADD,
"values" => array($newPwd)
)
);
ldap_modify_batch($conn, "cn=John Smith,ou=Accounting,dc=ad,dc=example,dc=com", $mods);
ldap_close($conn);
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64317&edit=1
Thread (3 messages)