dream04110 2014-06-14 08:20
浏览 448

ldap_add():添加:约束违例

I am learning how to perform CRUD operations on a LDAP directory and using ApacheDS for the purpose.I am trying to add a new user but keep getting the following warning:

Warning: ldap_add(): Add: Constraint violation

Here's the php code I am using:

<?php
function ldap_add_user($user)
{
    include('ldap_config.php');
    include('ldap_admin.php');

    $connect = ldap_connect($host, $port);

    if ($connect) 
    {   
        ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);

        $bind = ldap_bind($connect,$username,$password); 

        $info['uid'] =  $user['mail_id'];
        $info['userPassword'] = $user['password'];
        $info['cn'] =  $user['firstname'].' '.$user['lastname'];
        $info['sn'] =  $user['lastname'];
        $info['objectClass'][3] = "inetOrgPerson";
        $info['objectClass'][2] = "organizationalPerson";
        $info['objectClass'][1] = "person";
        $info['objectClass'][0] = "top";
        $dn="uid=".$user['mail_id'].", ou=auth_users, o=mycompany";

        $r = ldap_add($connect,$dn,$info);
        ldap_close($connect);
        return true;
    }
    else
    {   
        return false;
    }
}
?>

And,the interesting thing is that the above code works just fine when I use a numeric password for the $user['password'], but when I pass alphanumeric or non-numeric passwords I get the warning mentioned above.

  • 写回答

1条回答 默认 最新

  • dowm41315 2015-10-24 20:40
    关注

    If you are using Apache Directory Studio then right click on connection, select "Open Configuration" and navigate to "Password Policies" tab. You will see "Check Quality" option on right side.Turn it to "Disabled".

    评论

报告相同问题?

悬赏问题

  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法