php-ldap works in commandline but not through browser

php-ldap works in commandline but not through browser

am 15.10.2009 07:57:16 von chima s

Hi All,

I am using tring with sample program to connect the ldap using php.
Below is the sample code:

============================================================ ==========

echo $test=ldapAuthenticate('username','password','domainname');

function ldapAuthenticate($username,$password, $domainname) {
global $ds;

$ds = ldap_connect("xxx.xxx.xxx.xxx");

if($ds)
{
if(ldap_bind($ds))
{
$search = ldap_search($ds, "ou=$domainname,dc=comapny", "uid=$username");

if( ldap_count_entries($ds,$search) != 1 )
{
echo "Error processing username -- please try to login again. (Debug 3)";
return 0;
}


$info = ldap_get_entries($ds, $search);

$bind = @ldap_bind($ds, $info[0][dn], $password);
if( !$bind || !isset($bind))
{
echo "Login failed -- please try again. (Debug 4)";
return 0;
}
$search = ldap_search($ds, "ou=$domainname,dc=company", "uid=$username");

$info = ldap_get_entries($ds, $search);
if( $username == $info[0][uid][0] )
{
return 1;
}
else
{
return 0;
}
}
else
{
echo "\nAnonymous bind to LDAP FAILED. Contact Tech Services! (Debug 2)\n";
return 0;
}
}
else
{
echo "technical services! (Debug 1)";
return 0;
}
}
?>
============================================================ ===============

When i execute this program with command line its works fine

But when is try this in browser its not working. It struck with bind
statement and not throwing any error,

Following are the version of application:

httpd-2.0.52-41
php-5.2.9-1
openldap-2.2.13-8

Note: There is no filrewall between web server and ldap server.

Regards
Chima.s

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: php-ldap works in commandline but not through browser

am 15.10.2009 15:47:11 von xfedex

Did you check both php.ini files?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: php-ldap works in commandline but not through browser

am 16.10.2009 05:45:31 von chima s

Hi,

ldap extension was loaded in the php.ini file.

php -i |grep ldap
/etc/php.d/ldap.ini,
ldap
RCS Version => $Id: ldap.c,v 1.161.2.3.2.14 2008/12/31 11:17:39 sebastian Exp $


Regards
Chima.s


On Thu, Oct 15, 2009 at 7:17 PM, wrote:
> Did you check both php.ini files?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php