PHP LDAP ldap_mod_replace [英] PHP LDAP ldap_mod_replace
问题描述
我正在尝试创建一个界面,以直接在站点上为曾经使用LDAP的用户更改LDAP用户的密码.我正在使用ldap_mod_replace.对于更改它,我需要一个数组$ userdata.现在,我想从文本字段中设置密码.
I am Trying to Create an Interface to Change Passwort of a LDAP User direct on the site for Users that arent used to LDAP. I am using ldap_mod_replace. for Changing it i need an Array $userdata. Now i want to set the Passwort from a Textfield.
创建数组需要怎样做以及还有什么
How and what else do i need to create the array
这是我保存功能中的代码.
This is the code from my save function.
function save($ds, $dn) {
echo "0";
$newPassword = $_POST['newPassword'];
$repeatNewPasword = $_POST['repeatNewPasword'];
echo "1, $repeatNewPasword, $newPassword";
//newPassword $userdata
//......
echo "2";
if ($repeatNewPasword == $newPassword) {
echo "3";
ldap_mod_replace ($ds, $dn, $userdata);
echo "Erfolgreich, $ds, $dn, $userdata";
}
else {
echo "Passwords are different";
}
}
我不习惯LDAP,根本不了解ldap_mod_replace函数.
im not used to LDAP and dont know the function ldap_mod_replace at all.
推荐答案
这取决于密码存储在其中的属性字段.如果密码属性为"password",则需要使用此密码:
It depends on the attribute-field the password is stored in. If the password-attribute is "password" you'll want to use this:
$ userdata = ['password'=>];
$userdata = ['password' => ];
通常,键的值是一个数字数组,但由于它是密码,因此只包含一个值,而不包含多个值.因此,您也可以直接添加值.
Normally the value to the key is a numeric array but as it's a password it only contains one value and not multiple ones. Therefore you can also add the value directly.
请不要忘记根据LDAP服务器使用的密码策略对密码进行哈希处理.您可能要使用CLI工具"ldappasswd"来正确地对密码进行哈希处理.而且,您将需要作为更改密码的用户或具有管理权限的用户绑定到LDAP服务器,因为passeord属性通常是不可读的,因此对其他用户而言是不可写的.
Don't forget to hash the password according to the password policy used by the LDAP-Server. You might want to use the CLI-tool "ldappasswd" to properly hash the password. And you will need to bind to the LDAP-server either as the user you are changing the password for or as a user with administrative rights as the passeord-attribute normaly isn't readable and therefore not writable for others.
这篇关于PHP LDAP ldap_mod_replace的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!