2018-10-31 09:32



I'm trying to add the user to my LDAP server. But I'm getting the below error.

PHP Warning:  ldap_add(): Add: Referral

$ds = ldap_connect("HOST","PORT"); 
if ($ds) {
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
$bind = ldap_bind($ds, "adminusername", "Passwrd");
echo $bind;
// prepare data
$base_dn = 'CN=Manus Test,OU=UserAccounts,,DC=rk';
$info["displayName"]= "Jdkd sjs";
$info["cn"] ="Manus Test";
$info["objectclass"][0] = "top";
$info["objectclass"][1] = "person";
$info["objectclass"][2] = "inetOrgPerson";
$info["objectclass"][3] = "organizationalPerson";

// add data to directory
$r = ldap_add($ds, $base_dn, $info);
echo "Bind result is " . $r . "<br />";

Please let me know any suggestions.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dtebrq0245 dtebrq0245 3年前

    Referrals can be returned if you are talking to a slave LDAP server (essentially a read-only copy of the directory). If you know you are talking to a server hosting a writable copy of the replica, referrals are also returned when the DN base is not something hosted by that server.

    Looking at the code above, ",DC=rk" is unusual. I generally see the "domain" components broken out so becomes "dc=rk,dc=com". Use an ldap browser to verify the pattern for fully qualified DNs in your directory.

    点赞 评论 复制链接分享