Link to home
Start Free TrialLog in
Avatar of hibster
hibster

asked on

PHP and LDAP: php_ldap.dll giving "Access is Denied" error

Hi everyone. I've been stuck on this problem for a while, and it's driving me nuts, so I'd greatly appreciate the help!

I have PHP set up on a Microsoft IIS 5.x server. For authentication purposes, I am trying to query a Microsoft Exchange of user information via LDAP. Now, I have never used LDAP before, but I followed the instructions very closely. Here is what I've done so far:

- Placed php_ldap.dll and libsasl.dll in the c:/php/extensions folder
- Uncommented the extension for php_ldap.dll in the php.ini file and set the extension_dir to c:/php/extensions
- Gave the IUSR_machine_name full privileges to the php_ldap.dll and libsasl.dll files, as well as the folders they reside in.
- I have tried placing the .dll's in the c:/winnt/system32 directory, and still the same problem. I have also downloaded all the .dll's in the windows binary version of the PHP download and placed them all in the system32 directory.

The problem I'm having is that whenever I try to access the website I get a pop-up message on the server that states:
"Unknown(): Unable to load dynamic library 'c:/php/extensions/php_ldap.dll' - Access is denied". This occurs whenever I try to access any of the PHP pages, not just the one that tries to connect to the Exchange Server via LDAP. One more possible clue is that my phpInfo() page doesn't mention anything about LDAP being used in the system.

My hunch is that this is a permissions thing, but I've tried everything I know to do as far as that goes! Anybody out there ever had this problem or have any ideas? I'd be very grateful.

Thanks,
Brian Hibma
SOLUTION
Avatar of pcaylor
pcaylor

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hibster
hibster

ASKER

Peter, thanks for your comment.  Actually, I have already tried your approach to give the IUSR_ account full privileges on the entire drive, and still it didn't work.  So it really doesn't seem to be an NTFS issue.  I'm getting more suspicious of IIS (I have absolutely no experience with it, I'm an Apache man myself...stuck in a company brainwashed with Microsoft!).  Anybody know if IIS has its own set of file permissions or in any way overrides the NTFS permissions?

Thanks again Peter, but don't think that's it (wish it was!)

Brian
This is a long shot, but try checking the Application Protection setting for the site.  (Right click on the site, select properties, then the Home Directory tab)  I've had best luck with PHP under the medium setting.

Also, are you running PHP in CGI or ISAPI mode?

-Peter
Avatar of hibster

ASKER

I'm running PHP in CGI mode; it seemed the easiest at the point of install.

Yeah, I checked into the Application Protection properties and I already had it set at medium.  I've tinkered with all those setting so many times trying to find this solution that I find it hard to imagine I missed one.

Again, thanks for the thoughts,

Brian
It's a pain in the neck to switch, but try running PHP in ISAPI mode.  I think this is what's causing the problem:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q311481

Unfortunately the MS article doesn't help much with the resolution, so that's why I'd suggest switching to ISAPI mode.

-Peter
Hello Brian,

as Peter correctly stated in his first comment, this is an NTFS permissions issue.

Inspired by Peter's comment, I tried giving IUSR_machinename "read" and "execute" rights for the whole system32 directory. I also tried to set the permissions for the entire drive like you did. Both methods have two things in common: They are a potential security risk, and they don't work.

You must explicitly give IUSR_yourmachinename the necessary "read" and "execute" rights for each one of the DLLs that you copied into the c:\winnt\system32\ directory. After you've done that, everything will work fine.

Hope this helps.

- Hotaru
Avatar of hibster

ASKER

Hi Hotaru,

Your comment makes so much sense!  Problem is, though that is the intuitive answer, it doesn't work.  I have tried just about every combination of permissions settings, even going so far as to make the entire machine vulnerable (obviously I didn't leave it that way) and still, the same error.  I have tried giving each .dll the correct permissions for the IUSR_machinename account, and no luck.  I have tried giving the IUSR_machinename the proper permissions on the entire parent folder with files in the folder inheriting the permissions, and no luck.

An update on this story is that instead of wasting my time with this issue, I convinced my manager to switch over to a Linux box.  Everything went smoothly from there, so perhaps the accepted answer should be the first one who comments "Move to Linux!" :) ...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You probably just require another dll to load the ones that it is having problems loading.

It is not a matter of finding them, or loading them, or permissions.  It just doesn't see the other dependant dll's.

If you copy the dll's from the "dlls" (and maybe "sapi") directory folder from the php install, to the directory where you are trying to load the extensions from, it will probably find the necessary dll's and load.  I just did this myself.  It doesn't really tell you which dll you needed though. - Eric

 

Sorry, I should have read that a little closer, it looks like you do have an access denied issue, not a module not found issue like most people have, when it can't load the proper dll.
Avatar of hibster

ASKER

Well, in the time since I have posted this I have left the company that I was having this problem at without ever resolving the issue.  So while I don't have to deal with it anymore, it still irks me.  I still don't believe that it was a permissions issue, but was more of a .dll location issue, but that's my own intuition.  Anyhow, I am unable to try any more of your suggestions (thank you for them).

One other suggestion I received was from an individual who emailed me having the same problem.  I will post it here in hopes it helps someone else out who hit this same problem:

Quote:
I worked at this problem for a couple of days non-stop and then took a
break.  When I came back to I simply copied ssleay32.dll & libeay32.dll into
my PHP directory (in my case c:\php) and also moved my php_ldap.dll into
that same directory.  I then changed my php.ini file to look at c:\php for
my extensions.

Wa-la!  I couldn't believe my eyes.  It was actually working.  Now the only
problem is that I'm not sure if it was something that I did earlier in
conjunction with this or not.  At least it's working. (Whew!)