|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patchesldap_modify_batch.patch (last revision 2013-02-27 23:35 UTC by ondra dot hosek at gmail dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-06-10 11:05 UTC] martin dot keckeis1 at gmail dot com
[2015-06-10 11:51 UTC] ondra dot hosek at gmail dot com
-Status: Open
+Status: Closed
[2015-06-10 11:51 UTC] ondra dot hosek at gmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 12:00:02 2025 UTC |
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); ?>