Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using php 5.2 with IIS7.5.

I have a network share on a NAS that is username and password protected. I cannot disable or change authentication info on the NAS. I need to be able to access that network share via php.

I've done the following:

  1. Created new user in windows whose username and password matches those on the NAS.
  2. Created IIS application pool that uses this same auth info.
  3. Created a web.config file inside of the php app directory with an impersonation turned on, using the same auth info.

    identity impersonate="true" password="ThePass" userName="TheUser" />

  4. Turned on ASP.NET impersonation in the application authentication in IIS.

None of this seemed to work with this simple line of code in php:

$dir = opendir("\\\\someservername\\somesharename");

Warning: opendir(\someservername\somesharename) [function.opendir]: failed to open dir: No error in C:\websites\site\forum\testing.php on line 7

So, I decided to test the configuration with ASP.NET.

string[] diretories = System.IO.Directory.GetDirectories("\\\\someservername\\somesharename");

The asp.net test worked perfectly.

Going further down the rabbit hole, I ran phpinfo() and checked the username info in it. Down in the "Environment" section of phpinfo, I found the "USERNAME" item. Its value was "TheUser," as was what I expected.

Everything points to the system being configured correctly until I tried:

echo get_current_user();

Which returned, "IUSR." That surely isn't what I expected.

This question could easily be cross posted to stackoverflow, but I think it's a configuration issue.

So, how in the world do I get php + IIS7.5 to read from a foreign network share?

share|improve this question
    
FWIW, I've found there are so many gotchas and undocumented features with IIS/NTLM that working with user-level permissions access is just not worth the pain (OTOH using smbfs or smbclient on Linux works fine - and behaves the same way for every client) –  symcbean Mar 25 '12 at 22:41
    
Unfortunately, moving over to Linux is not an option. This is for a 3rd party php app, where the rest of the site is in ASP.NET. –  darthg8r Mar 26 '12 at 2:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.