[Date Prev][Date Next] [Chronological] [Thread] [Top]

Php and OpenLDAP: "attribute type undefined" error


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.


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


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

    // añadimos los datos al directorio

    $r=ldap_add($ds,"dc=company, dc=com", $info); // $info

} else {
    echo "Ha sido imposible conectar al servidor LDAP";