LDAP添加用户错误成功

时间:2017-04-21 14:59:56

标签: php ldap

我尝试使用以下代码将用户添加到freeipa。代码返回成功,但是当我转到freeipa UI时,用户不可见。如果我尝试重新插入它将无法告诉用户已经存在。什么可以?感谢

    $con = ldap_connect($server);

ldap_set_option($con, LDAP_OPT_PROTOCOL_VERSION, 3);



// bind anon and find user by uid

$user_search = ldap_search($con,$dn,"(|(uid=admin))");

$user_get = ldap_get_entries($con, $user_search);

$user_entry = ldap_first_entry($con, $user_search);

$user_next = ldap_next_entry($con, $user_entry);

$user_dn = ldap_get_dn($con, $user_next);



if (ldap_bind($con, $user_dn, "adminpass") === false) {

    $message[] = "Error E101 - Current Username or Password is wrong.";

}else{

    $info['givenName'] = "test";

    $info['cn'] = "test";

    $info['sn'] = "user";

    $info['mail'] = "test@localhost";

    $info['objectclass'][0] = "inetorgperson";        

    if(ldap_add($con, "cn=test,cn=users,cn=accounts,dc=domain,dc=net", $info) === false){

    $error = ldap_error($con);

    $errno = ldap_errno($con);


    $message[] = "$errno - $error";

}else{

    $message[] = "ok";

}


}

0 个答案:

没有答案