Hi,
I can't load data into ldap via php. I always gfet this error mesage: ldap_add() [function.ldap-add]: Add: Undefined attribute type in www/test/testldap2.php on line 60
LDAP-Errno: 17
LDAP-Error: Undefined attribute type
I don't get it since the same définition can be loaded using the command line with a file and I can modifiy entries using php.
Any idea would be welcome.
Thanks
Config: PHP5 (last version), apache 1 (last version) and openldap (last version)
// Eléments d'identification LDAP
$ldaprdn = 'Manager'; // DN ou RDN LDAP
$ldappass = 'secret'; // Mot de passe associé
//Connexion au serveur LDAP
$ldapconn = ldap_connect("localhost")
or die("Impossible de se connecter au serveur LDAP.");
$setoption = ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
if ($ldapconn) {
//Connexion au serveur LDAP
$ldapbind = ldap_bind($ldapconn,"cn=Manager, dc=ldap,dc=toto,dc=fr",$ldappass);
// Identification
if ($ldapbind) {
echo "Connexion LDAP réussie <br>";
} else {
echo "Connexion LDAP échouée";
}
}
Text file used for the command line:
$info['dn'][0] = 'uid=monnnom,ou=people,o=monorganisation,dc=ldap,dc=toto,dc=fr';
$info['cn'][0] ='monnnom';
$info['objectClass'][0]='top';
$info['objectClass'][1]='person';
$info['objectClass'][2]='organizationalPerson';
$info['objectClass'][3]='inetOrgPerson';
$info['ou'][0] = 'people';
$info['o'][0]='monorganisation';
$info['sn'][0]='monnnom';
$info['displayName'][0]='monnnom';
$info['homePhone'][0]='44 44 44 44 44';
$info['homePostalAddress'][0]='Mon adresse';
$info['mail'][0]='mailtiti@monmail.com';
$info['preferredLanguage'][0]='fr';
$info['userPassword'][0]='toto';
$info['telephoneNumber'][0]='0000000000';
$info['uid'][0]='monnnom';
$dn = $info['dn'][0];
$res = ldap_add($ldapconn,$dn,$info);
if (!$res) {
echo "LDAP-Errno: " . ldap_errno($ldapconn) . "<br />\n";
echo "LDAP-Error: " . ldap_error($ldapconn) . "<br />\n";
}
// Ajoute les données au dossier
$res = ldap_add($ldapconn,$info['dn'],$info);
if (!$res) {
echo "LDAP-Errno: " . ldap_errno($ldapconn) . "<br />\n";
echo "LDAP-Error: " . ldap_error($ldapconn) . "<br />\n";
}
dn : uid=taiti,ou=people,o=monorganisation,dc=ldap,dc=toto,dc=fr
cn : taiti
objectClass : top
objectClass : person
objectClass : organizationalPerson
objectClass : inetOrgPerson
ou: people
o : monorganisation
sn : taiti
displayName : titi
homePhone : 01 44 44 44 44 44
homePostalAddress: Mon adresse
mail : mailtiti@monmail.com
preferredLanguage : fr
userPassword : toto
telephoneNumber : 0000000000
uid:taiti