TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   ldap server (http://www.talkphp.com/advanced-php-programming/2643-ldap-server.html)

Gibou 04-16-2008 12:50 PM

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 :)

Jenski 04-29-2008 01:54 PM

What are you using to store your users?
Active Directory? OpenLDAP? something else?

Gibou 04-29-2008 06:56 PM

I use OpenLDAP.

I've succeed to perform researches in the ldap serv but still not to add.

Jenski 07-10-2008 10:11 AM

has the user you binded the connection with got permissions to add things?

I had the same problem, but after talking to our network administrator the user I tried to bind with couldn't do it the 'normal' way anyway...

Gibou 07-10-2008 10:38 AM

No, in fact, it was only a syntax error. It's good for me since a moment :-)

Thank you


All times are GMT. The time now is 08:15 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0