是否有可能使用活动目录使inetOrgPerson成为ldap php中posixGroup的成员

时间:2015-09-05 16:18:16

标签: php ldap lamp

是否有可能使inetOrgPerson成为posixgroup的成员而不是在cn中添加手动条目,我使用php和ldap,但我似乎遇到了这个:

 Modify: Object class violation

代码:

 $ldap = ldap_connect("localhost") or die("Unable to connect to server.");
 ldap_set_option($ldap,LDAP_OPT_PROTOCOL_VERSION,3);
 $dn = "cn=admin,dc=*******,dc=com";

 ldap_bind($ldap,$dn,"*****") or die("Unable to connect to server..");
 $dn = "cn=********,cn=*********,cn=*********,ou=A*******,dc=********,dc=com";

      $entry["cn"] = "MerPaul";
      $entry["objectClass"] = "inetOrgPerson";

      ldap_mod_add($ldap,$dn,$entry);

我做错了什么?

1 个答案:

答案 0 :(得分:2)

LDAP中的objectClass具有可选和必填字段。 inetOrgPerson也不例外。

inetOrgPerson的必填字段为sncn

  $entry["cn"] = "MerPaul";
  $entry["sn"] = "Joe"
  $entry["objectClass"] = "inetOrgPerson";

  ldap_mod_add($ldap,$dn,$entry);