Tuesday 9 February 2010

PHP is_dir/opendir on UNC under IIS

Been really banging my head against a wall on this problem and last night I finally solved it. I have been trying to open a Windows network share by providing is_dir with a UNC. I got this working under Apache but I couldn’t get it up and running under IIS6.

The solution is really simple;

1. Right click the virtual directory that houses the script running is_dir

2.
Select ‘Properties’

3.
Click the ‘Directory Security’ tab

4.
Under ‘Authentication and access control’ click ‘Edit’

5.
Make sure ‘Enable anonymous access’ is selected

6. Change the user name and password to a user that has access to the network share



For step 6 above I created a dedicated ‘web user’ that I have given only access to the share I wanted, in theory I think you should be able to use the IUSR_machinename user, but I couldn’t get it to work and as part of my process of elimination creating a ‘web user’ resolved the problem.

As the share I was testing the above setup with resided on a system running F-Secure I had to disable F-Secure so that the web server could access the share, I was quite surprised by this.