Jeroen Hulshof
Jeroen Hulshof

Reputation: 61

OpenLDAP PHP Add birthdate attribute

I'm trying to add Date of birth attribute from naturalPerson schema in PHP, but i get the error: 21, invalid syntax. What am i doing wrong?

$addToGroup['objectclass'][2] = "inetOrgPerson";
$addToGroup['objectclass'][3] = "naturalPerson";
$addToGroup['dateofbirth'] =  "2020-01-01";

Thanks in advance.

Edit according to feedback in the comments:

Warning: ldap_add(): Add: Undefined attribute
Line: 54

Full code:

$addToGroup['cn'] = $email;
$addToGroup['givenname'] = $first_name;
$addToGroup['sn'] = $last_name;
$addToGroup['street'] = $street_name;
$addToGroup['postalCode'] = $postal_code;
$addToGroup['telephonenumber'] = $phone;
$addToGroup['userpassword'] = $password_hash;
$addToGroup['birthdate'] = "20200101";
$addToGroup['objectclass'][0] = "top";
$addToGroup['objectclass'][1] = "person";
$addToGroup['objectclass'][2] = "inetOrgPerson";
$addToGroup['objectclass'][3]= "naturalPerson";

// Add user to selected group
$addToGroupQuery = "cn=$email,dc=ritsemabank,dc=local";


 LINE 54: $add = ldap_add($ldapconn, "cn=$email,cn=klanten,dc=ritsemabank,dc=local", $addToGroup);

I get the error after adding these 2 lines of code:

$addToGroup['objectclass'][2] = "inetOrgPerson";
$addToGroup['objectclass'][3] = "naturalPerson";
$addToGroup['dateofbirth'] =  "2020-01-01";

I am trying to use this link: https://ldapwiki.com/wiki/Date%20Of%20Birth to add dateofbirth attribute to the user i want to create.

I hope that this code provides the information needed to fix my problem.

Upvotes: 1

Views: 688

Answers (0)

Related Questions