[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Php and OpenLDAP: "attribute type undefined" error
Hi!
I've been trying to use a PHP 4.2 script to add LDAP entries (I'm using
OpenLDAP 2.0.23). To do so, I used a simple PHP script example as reference
but I just can't find the way to make it work since I keep getting a "dn:
attribute type undefined" error.
I have no problems adding entries using the ldapadd command line and a .ldif
file. Here are both files... I hope someone will be able to help me. Thanks.
LDIF FILE
====================
dn: uid=name.lastname, ou=subcarpeta1, dc=company, dc=com
cn: Name Lastname
sn: segundo
objectClass: top
objectClass: person
objectClass: inetOrgPerson
objectClass: qmailUser
mailHost: my.mail.com
mailMessageStore: /var/qmail/maildirs/name.lastname
uid: name.lastname
userPassword: {crypt}xxxxx.xxxxxx/xxxxxxxxxxxxx.
mail: name.lastname@company.com
mailAlternateAddress: name.lastname@company.com
PHP SCRIPT
======================
<?php
$ds=ldap_connect("localhost"); // Asumimos que el servidor LDAP está en el
// servidor local
echo "El resultado de la conexión es ".$ds."<p>";
if ($ds) {
// autentificarse con el dn apropiado para tener permisos de
modificación
$r=ldap_bind($ds, "cn=manager, dc=company ,dc=com", "secret");
// preparamos los datos
$info["dn"]="uid=name.lastname, ou=subcarpeta1, dc=company, dc=com";
$info["cn"]="Name Lastname";
$info["sn"]="segundo";
$info["objectClass"]="top";
$info["objectClass"]="person";
$info["objectClass"]="inetOrgPerson";
$info["objectClass"]="qmailUser";
$info["mailHost"]="my.mail.com";
$info["mailMessageStore"]="/var/qmail/maildirs/name.lastname";
$info["uid"]="name.lastname";
$info["userPassword"]="{MD5}xxxxxxxxxxxxxxxxxxxxx==";
$info["mail"]="name.lastname@company.com";
$info["mailAlternateAddress"]="name.lastname@company.com";
// añadimos los datos al directorio
$r=ldap_add($ds,"dc=company, dc=com", $info); // $info
ldap_close($ds);
} else {
echo "Ha sido imposible conectar al servidor LDAP";
}
?>