tags:

views:

23

answers:

1

Hello,

Currently, I'm working on PHP web application on wamp environment.

I'm quite new with ldap and right now, I have a pretty simple problem about it.

After I enabled LDAP support in PHP. I have tried to call ldap function with the following code:

<?php

// LDAP variables
$ldaphost = "ldap.example.com";  // your ldap servers
$ldapport = 389;                 // your ldap server's port number

// Connecting to LDAP
$ldapconn = ldap_connect($ldaphost, $ldapport)
          or die("Could not connect to $ldaphost");

echo $ldapconn;

?>

The problem is when I run this file, I've got no result. I can't see whether it's failed or not and after function "ldap_connect", whatever I tried to put it there. It doesn't work, even simple command e.g. echo "hello world";

What should I do?

Please Suggest.

+1  A: 

ldap_connect returns resource. When trying to echo or doing var_dump($ldapconn); you should see something like resource #1 - it means your connection is ready to use. If your connection failed, die() will work for sure and probably PHP warning will be thrown.

A.
Thanks for suggestion, I've tried follow your suggestion but I can't see any result, it's the same.
AnandaP
`var_dump` can't have no output at all, it dumps even null, so your script have to silently fail earlier. Do you have `php_ldap` extension turned on in your PHP? What is your `error_reporting` setting?
A.
I've tried:1. In php.ini, enable setting extension_dir,2. In php.ini, enable setting extension=php_ldap.dll,3.loading libeay32.dll and ssleay32.dll, 4.error_reporting(-1); I don't know how can I do better. Please suggest me anything u could imagine, I will try it all... Please
AnandaP
Maybe there is something interesting in Apache error log? Does echoing anything after `ldap_connect` work? If no, does echoing anything before `ldap_connect` work?
A.
There is no error in Apache error log (also in PHP error log) and nothing works atfer ldap_connect function but everything before ldap_connect work fine.
AnandaP
Check your phpinfo() output. Is there a section with ldap module settings? What is the integer value of error_reporting? What is the value of display_errors?
A.
This is what I've got from phpinfo() at ldap module section:LDAP Support enabledRCS Version $Id: ldap.c 287897 2009-08-30 15:33:59Z iliaa $Total Links 0/unlimitedAPI Version 3001Vendor Name OpenLDAPVendor Version 20409display_errors is on and value of error_reporting is 22519Is there any other place I can check?
AnandaP
Well, everything looks right, I have no idea what's wrong. The same code with the same configuration works for me.
A.
Thank you so much anyway. Last weekend I brought my laptop to continue this work at home. Surprisingly, I've got a result. Do you think it's because of the network?
AnandaP
Well, it may be that there's some kind of firewall in your network, but I'm not a proper person to ask about such things :)
A.