Hello ! ldap_add is expecting an ARRAY OF STRINGS (according to LDAP-specs) as third parameter. but your $info["objectclass"] is an array itself... maybe you try to implode it into one string... cheers, hope that helps... bb >Hello all, > >I have a problem with ldap function :/ > >Here is my ldap : >- dc=arzur,dc=local >- ou=Annuaire >+ cn=Benjamin DUPUIS >+ cn=Emeric GIRARD >+ cn=Fabrice DEPIL >+ cn=Fabrice GAUSSEN >+ cn=Jérôme LE MANSEC >+ cn=Olivier MATHE >+ cn=Sylvain BOUBOUNELLE > >Here is a LDIF file, (export of phpldapadmin) :* >*dn:cn=Benjamin1 DUPUIS1,ou=Annuaire,dc=arzur,dc=local >cn: Benjamin1 DUPUIS1 >objectClass: top >objectClass: person >objectClass: organizationalPerson >objectClass: inetOrgPerson >objectClass: mozillaAbPersonObsolete >sn: DUPUIS > >/***************************************************************/ >My connection/search work fine >$ds = @ldap_connect("localhost"); >@ldap_set_option( $ds, LDAP_OPT_PROTOCOL_VERSION, 3 ); >@ldap_set_option( $ds, LDAP_OPT_REFERRALS, 0); > >if ($ds) { >$r=ldap_bind($ds,"cn=Manager,dc=arzur,dc=local","toto"); >$sr=ldap_search($ds,"ou=Exterieur,dc=arzur,dc=local", "mail=*"); >$info = ldap_get_entries($ds, $sr); > >echo '<table><tr><td>Nom Prénom</td><td>Mail</td></tr>'; >for ($i=0; $i<$info["count"]; $i++) { >echo '<tr>'; >echo '<td>' . $info[$i]["cn"][0] . '</td>'; >echo '<td>' . $info[$i]["mail"][0] . '</td'; >} >ldap_close($ds); >} >else { >echo '<h4>Impossible de se connecter au serveur LDAP.</h4>'; >} >/***************************************************************/ >But ldap_add not working with error Warning: ldap_add(): Add: Undefined >attribute type in /srv/www/htdocs/gestioninterne/CLDAP.php on line 70 > >Here's the code : >if ( (isset ($_POST['envoi']) ) && ($_POST['envoi']=="ok")) { >$ds = ldap_connect("localhost"); >ldap_set_option( $ds, LDAP_OPT_PROTOCOL_VERSION, 3 ); >ldap_set_option( $ds, LDAP_OPT_REFERRALS, 0); >$r=ldap_bind($ds,"cn=Manager,dc=arzur,dc=local","toto"); > >$cn=$_POST['givenName'].' '.$_POST['sn']; >$info["cn"]="$cn"; // Prenom NOM >$info["objectClass"][0]="mozillaAbPersonObselete"; >/*$info["objectClass"][0]="top"; >$info["objectClass"][1]="person"; >$info["objectClass"][2]="organizationalPerson"; >$info["objectClass"][3]="inetOrgPerson"; >$info["objectClass"][4]="mozillaAbPersonObselete";*/ >$info["sn"]=$_POST['sn']; // Nom > >$cn.=",ou=Exterieur,dc=arzur,dc=local"; >$cnFinal="cn=".$cn; >echo >>$cnFinal,'<br>$info[objectClass]',$info["objectClass"],'<br>$info[sn]=',$info["sn"],'<br>$info[cn]=',$info["cn"]; >$r=ldap_add($ds,$cnFinal,$info); >ldap_close($ds); >} > >/*****************************************************************/ >Here's the result of my echo : >cn=Benjamin BOUBOUNELLE,ou=Exterieur,dc=arzur,dc=local >$info[objectClass]Array >$info[sn]=BOUBOUNELLE >$info[cn]=Benjamin BOUBOUNELLE >*Warning*: ldap_add(): Add: Undefined attribute type in >*/srv/www/htdocs/gestioninterne/CLDAP.php* on line *70 > >*/*****************************************************************/ > >Anyone can help me, I'm on since 10 hours :( > >Regards > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > > Björn Bartels -Development/IT-Services- ---------------------------------------------- dbusiness.de gmbh digital business & printing gmbh Greifswalder Str. 152 D-10409 Berlin Fon: [0.30] 4.21.19.95 Fax: [0.30] 4.21.19.74 www.dbusiness.de info@xxxxxxxxxxxx ftp://dbusiness.dyndns.org
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php