Search code examples
phpldaplamp

Is it possible to make a inetOrgPerson a member of a posixGroup in ldap php using active directory


Is it possible to make a inetOrgPerson a member of a posixgroup rather than added a manual entry inside of cn, im using php and ldap but i seem to come across this:

 Modify: Object class violation

code:

 $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);

what am i doing wrong?


Solution

  • And objectClass in LDAP has optional and mandatory fields. inetOrgPerson is no exception.

    The required fields of inetOrgPerson are sn and cn.

      $entry["cn"] = "MerPaul";
      $entry["sn"] = "Joe"
      $entry["objectClass"] = "inetOrgPerson";
    
      ldap_mod_add($ldap,$dn,$entry);