logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Other Software View previous topic :: View next topic
Reply to topic   Topic: [SOLVED] PHP ldap_bind doesn't work via Apache fcgid
Author
gcleaves



Joined: 01 Dec 2009
Posts: 14

PostPosted: Thu 03 Dec '09 13:30    Post subject: [SOLVED] PHP ldap_bind doesn't work via Apache fcgid Reply with quote

Does anybody have a clue as to why I can successfully use the PHP function ldap_bind when executed as an Apache module (or from the command line) but it fails when used under mod_fcgid? PHP can't bind to the LDAP server, always fails. This is happening for both PHP 5.2.4 and 5.3.1.

Code:
Unable to bind to server: Can't contact LDAP server

I haven't seen anybody else complaining of this. Is anybody using PHP ldap under fcgid?


Last edited by gcleaves on Thu 03 Dec '09 23:34; edited 1 time in total
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Thu 03 Dec '09 17:17    Post subject: Reply with quote

I tried it with an example source from php.net and it works with fcgid.
I use PHP NTS 5.3.1 on XP with apache 2.2.14 to Windows 2003 small business server

Code:

<?php

//anonymen ldap bind

/
$ldapconn = ldap_connect("ldap.example.com")
    or die("Could not connect to LDAP server.");

if ($ldapconn) {

    // anonymes binding
    $ldapbind = ldap_bind($ldapconn);

    if ($ldapbind) {
        echo "anonymes LDAP bind success...";
    } else {
        echo "anonymes LDAP bind fail...";
    }
 
}
   
?>
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Thu 03 Dec '09 17:25    Post subject: Reply with quote

Well the new LDAP is a bit difficult. Older code did not work. So I tried something.

But this works for me
Code:

$con = ldap_connect('ldap://ldap.example.com');
ldap_set_option($con, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($con, LDAP_OPT_REFERRALS, 0);
var_dump(ldap_bind($con, 'user@example.com', 'password'));
Back to top
gcleaves



Joined: 01 Dec 2009
Posts: 14

PostPosted: Thu 03 Dec '09 17:58    Post subject: Reply with quote

Are you connecting to an Active Directory server or a normal LDAP server? I'm having the problem with AD. Your code example below works for me under Apache PHP module but not mod_fcgid.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Thu 03 Dec '09 18:06    Post subject: Reply with quote

There is a real AD server (Windows 2003 for small business).

if you use the second code. What kind of error do you get?
Back to top
gcleaves



Joined: 01 Dec 2009
Posts: 14

PostPosted: Thu 03 Dec '09 18:14    Post subject: Reply with quote

Quote:
if you use the second code. What kind of error do you get?

this:
Code:
Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Can't contact LDAP server in D:\xxx\ad.php on line 8
bool(false)

It's very strange. As I said above, this code DOES work (I am able to bind successfully) from the command line or via Apache module. I am trying to bind to an Windows Server 2003 Standard Edition.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Thu 03 Dec '09 18:47    Post subject: Reply with quote

Do you use different php.ini's or the same? Which *:exe did you use for your trial and for your fcgid? both times php-cgi.exe ?
Back to top
gcleaves



Joined: 01 Dec 2009
Posts: 14

PostPosted: Thu 03 Dec '09 19:38    Post subject: Reply with quote

Quote:
Do you use different php.ini's or the same? Which *:exe did you use for your trial and for your fcgid? both times php-cgi.exe ?

I'm using different php.ini's and different versions of Apache (running on different TCP ports).

Working ldap_bind =
    Apache/2.2.4 (Win32) mod_auth_sspi/1.0.4 PHP/5.2.4
    Apache downloaded from apache.org.
    PHP downloaded from php.net.
    PHPIniDir "d:/w drive/php/"
    D:\W Drive\php\php.ini
    I assume this a TS version of PHP since it includes php5apache2_2.dll, is that correct?

Not-working ldap_bind=
    Apache/2.2.14 (Win32) mod_auth_sspi/1.0.4
    Apache downloaded from apachelounge
    DefaultInitEnv PHPRC "d:/w drive/php531"
    mod_fcgid-2.2b-w32.zip from apachelounge
    PHP NTS Version 5.3.1 MSVC9 (Visual C++ 2008) from PHP.net

Does that answer your question?
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3093
Location: Hilversum, NL, EU

PostPosted: Thu 03 Dec '09 20:10    Post subject: Reply with quote

Try to add:

DefaultInitEnv PATH "x:/xxxxx/php;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;"
DefaultInitEnv SystemRoot "C:/Windows"
DefaultInitEnv SystemDrive "C:"
DefaultInitEnv TEMP "C:/WINDOWS/Temp"
DefaultInitEnv TMP "C:/WINDOWS/Temp"
DefaultInitEnv windir "C:/WINDOWS"

Where xxxx points to you php dir.

Steffen
Back to top
gcleaves



Joined: 01 Dec 2009
Posts: 14

PostPosted: Thu 03 Dec '09 21:24    Post subject: Reply with quote

Stephen, that solved the problem Very Happy. Do you know why Question

Thanks very much to both of you for creating this site, compiling the great binaries and imparting your knowledge. It's people like you that make the Internet great.

You haven't heard the last of me, I'll be back with more questions.

Geoff
Back to top


Reply to topic   Topic: [SOLVED] PHP ldap_bind doesn't work via Apache fcgid View previous topic :: View next topic
Post new topic   Forum Index -> Other Software