Accessing mapped drive from php / iis

Hi,

I am using php on IIS7 to read data from a MSSQL database. One of the fields have a file path in it to an image file which I then need to access.

The problem is that the path has a mapped drive letter in it. I know I can access the file using the UNC name (i.e. "\\server\share\folder\file") but the users are accessing the drive as their W:\ drive, and so when they update the database, the field value ends up being "W:\folder\file", which php does not appear to be able to access. I assume this is because the user that php runs as (which according to phpinfo seems to be the computer account (i.e. "server$") does not have a drive mapping for W:\.

So while I could write a bit of code that took off the W:\ and replaced it with the UNC path, that isn't really bulletproof.

So my question is, does anyone know of a way to get a shared drive mapping into the profile of the php user, and can it be done safely? To be honest, I have got around this problem in the past by making W:\ a "real" drive on the server, so the local and mapped paths were identical, but I can't do this on this server.

Alternatively any other clever suggestions (and no, search and replace the values in the database is not an option).
LVL 2
Marco van BeekManaging DirectorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aaron TomoskySD-WAN SimplifiedCommented:
I try to save these values as /folder/file in the db. Then I have a server variable for the doc root (\\server\share)
This keeps things flexible with relative paths instead of absolute.
0
Marco van BeekManaging DirectorAuthor Commented:
Sorry, as I mentioned, search and replace the values in the database is not an option, and neither is changing the way users already work. I have to use what is in the database, and worse, what might be in the database in the future.
0
Aaron TomoskySD-WAN SimplifiedCommented:
If you can't control what goes into the db, then its better to make a replace on the fly function replacing w:\ (or something else) with your unc path for the server. Anything else is going to be a temporary patch when some users all of a sudden have a y:\ drive or something.

You can do it right in your SQL query string or in php. If you give us your relevant code we can help.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Dave BaldwinFixer of ProblemsCommented:
The user that IIS and PHP operates under (IUSR...) is restricted to the local machine and can't be given permissions on another machine.  In another question, someone said that a 'mapped' drive solved the problem for them because it made the drive 'local' but in a different question, someone else never got that to work.

What do you mean "by making W:\ a "real" drive on the server"?
0
dimmergeekCommented:
I had a similar probelm on an Intranet site I am developing.
I was not able to find a bullet-proof solution.
My work-around was to schedue a job each night which copies the images I need from my mapped drive to a folder on my web server.  That way, I don't need to worry about the mapped drive at all.
0
Marco van BeekManaging DirectorAuthor Commented:
Re "What do you mean "by making W:\ a "real" drive on the server"? ".

On that particular project I set up a dedicated partition for the data, and set the drive letter to be W: I then shared it at the root level (eg \\SERVER\W$), and mapped W:\ to it on the client computers, so as far as the web server was concerned, W was a real drive that it could access.

But I can't do this on this project. :-(
0
Dave BaldwinFixer of ProblemsCommented:
Then in my experience, if you can't make it look like a 'local' drive, you probably won't be able to connect to it with IIS.
0
Marco van BeekManaging DirectorAuthor Commented:
So the solution is either to use a separate partition for the data that can be given the same local drive letter as the clients use for the mapping, or to use a replacement script. I used an array that allows me multiple entries like "W:" => "\\SERVER\SHARE", and then my script loops through and replaces any matching drive letters with the UNC path. There seems to be short delay in the whole process (~1sec), over accessing local drive, which I assume is caused by going over the network.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.