Thread: ldap server
View Single Post
Old 04-16-2008, 12:50 PM   #1 (permalink)
Gibou
The Contributor
 
Gibou's Avatar
 
Join Date: Nov 2007
Location: France, near Paris
Posts: 53
Thanks: 6
Gibou is on a distinguished road
Default ldap server

Hi !

I have a question concerning the interaction between php and a ldap server.

supposing my server has the following configuration:
login: admin
pwd: adminpwd

The server is in my own machine so the server is localhost.

Here is my actual php code:

PHP Code:
// config
$server "localhost";
$port 389;
$racine "dc=elodig,dc=fr";
$rootdn "cn=admin,dc=elodig,dc=fr";
$rootpw "adminpwd";
$version 3;

// connection
$ds=ldap_connect($server);

if (
$ds)
{

  if(!
ldap_get_option($dsLDAP_OPT_PROTOCOL_VERSION$version))
    
ldap_set_option($dsLDAP_OPT_PROTOCOL_VERSION3);

  
$r=ldap_bind($ds,$rootdn,$rootpw);

  
$entry["cn"]="Robert Toto";

  
$entry["sn"]="Toto";
    
  
$entry["mail"][0]="robert.toto@elolo.fr";
  
$entry["mail"][1]="robert.toto@gmail.com";
 
  
$entry["objectclass"][0] = "person";
  
$entry["objectclass"][1] = "test";
  
$entry["objectclass"][2] = "test2";
  
$entry["objectclass"][3] = "test3";

  
// insert data into the ldap server
  
$r=ldap_add($ds"cn=Robert Toto,dc=elodig,dc=fr"$entry);
  
  
ldap_close($ds);
  
} else {
  echo 
"Connexion au serveur LDAP impossible";
  

And the error messages it returns:

Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Protocol error in... (line where ldap_bind is called)

Warning: ldap_add() [function.ldap-add]: Add: Invalid syntax in... (line where ldap_add is called)

I am on Linux, Kubuntu 7.10 Gutsy.
I have installed the following packages: slapd & ldap-utils, changed the password, make a test with a ldif file. In command line, it workds whithout any problem.

I've installed phpldapadmin which provides a graphical user interface but the result is the same: impossible to connect to the server after configuration.

Do you have any idea ?
Thank you :)
__________________
Wedus project's Website
Send a message via MSN to Gibou
Gibou is offline  
Reply With Quote