note 116789 added to function.ldap-modify
| From: | Anonymous | Date: | Sun, 01 Mar 2015 06:51:42 +0000 |
| Subject: | note 116789 added to function.ldap-modify | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201826@lists.php.net to get a copy of this message | ||
I ran into a rather annoying issue when trying to add a user to a usergroup in Active Directory.
Active Directory tends to not be particularly happy when you try modifying the "memberOf"
attribute (through ldap_mod_add/ldap_mod_replace), and will output a warning/error somewhere along
the lines of:
Warning: ldap_mod_add(): Modify: Server is unwilling to perform in ...
If you want to add a user to a usergroup, you need to add the user as a member of the group, rather
than adding to the memberOf attribute of the group:
<?php
function ldap_addToGroup($username, $group) {
$dn = "CN=$group,OU=Accounts,DC=DC1,DC=DC2"; // distinguished name/DN of the group
you want to add to
$info["member"] = "CN=$username,OU=Accounts,DC=DC1,DC=DC2"; // DN of the
user you want to add
return ldap_modify($ldapconn, $dn, $info);
}
?>
Hope this helps someone.
----
Server IP: 72.52.91.14
Probable Submitter: 153.107.97.167
----
Manual Page -- http://php.net/manual/en/function.ldap-modify.php
Edit -- https://master.php.net/note/edit/116789
Del: integrated -- https://master.php.net/note/delete/116789/integrated
Del: useless -- https://master.php.net/note/delete/116789/useless
Del: bad code -- https://master.php.net/note/delete/116789/bad+code
Del: spam -- https://master.php.net/note/delete/116789/spam
Del: non-english -- https://master.php.net/note/delete/116789/non-english
Del: in docs -- https://master.php.net/note/delete/116789/in+docs
Del: other reasons-- https://master.php.net/note/delete/116789
Reject -- https://master.php.net/note/reject/116789
Search -- https://master.php.net/manage/user-notes.php