TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-16-2008, 12:50 PM   #1 (permalink)
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
Old 04-29-2008, 01:54 PM   #2 (permalink)
The Wanderer
 
Join Date: Apr 2008
Location: Cloud 9
Posts: 19
Thanks: 0
Jenski is on a distinguished road
Default

What are you using to store your users?
Active Directory? OpenLDAP? something else?
Jenski is offline  
Reply With Quote
Old 04-29-2008, 06:56 PM   #3 (permalink)
The Contributor
 
Gibou's Avatar
 
Join Date: Nov 2007
Location: France, near Paris
Posts: 53
Thanks: 6
Gibou is on a distinguished road
Default

I use OpenLDAP.

I've succeed to perform researches in the ldap serv but still not to add.
__________________
Wedus project's Website
Send a message via MSN to Gibou
Gibou is offline  
Reply With Quote
Old 07-10-2008, 10:11 AM   #4 (permalink)
The Wanderer
 
Join Date: Apr 2008
Location: Cloud 9
Posts: 19
Thanks: 0
Jenski is on a distinguished road
Default

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...
Jenski is offline  
Reply With Quote
Old 07-10-2008, 10:38 AM   #5 (permalink)
The Contributor
 
Gibou's Avatar
 
Join Date: Nov 2007
Location: France, near Paris
Posts: 53
Thanks: 6
Gibou is on a distinguished road
Default

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

Thank you
__________________
Wedus project's Website
Send a message via MSN to Gibou
Gibou is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 12:33 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design