Accessing dir on another server - php


Hi all,
         Bascially I am trying to access a directory accroess the servers using php, somthing like (see code section )
But the problem is that it doesn't work, now if I trying doing the same thing being the server 'vmserver', it works fine. But if I trying to access it from another server, it doesnt work and gives me no error megs.
I have access to the server and if I try to access to from run.. then I can do that
I amm using IIS so may be I have to bind the authentications with IUSR account but thats a local account (as u may know, it has to be) so I cant do that#
Does any know how to get over this one?
Really very urgent for me as I have to migrate the web site


Thanks alot.

root = '\\\\vmserver\\C$\\Inetpub\\wwwroot\\reports'; 
$files = array(); 
$folderarray = array(); 
$count = 0; 
$hide = array(                  '_', 
                                '$'             ); 
$discard = false; 
 
if(is_dir($root)) 
{               if( $dh = opendir($root)) 
...

Open in new window

SameerMirzaAsked:
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.

SameerMirzaAuthor Commented:
any idea about this one guys?
0
gr8gonzoConsultantCommented:
How about mapping the network drive to a drive letter using the correct credentials and then looking at the drive letter with PHP?
0
Steve BinkCommented:
And that is most likely your issue - the user running PHP.  Since you are on Windows, this is probably an IUSR account or Network Service.  To complicate things further, Windows assigns those passwords, and I am certainly not the one to recommend you change that.  The IUSR account is only going to exist on the one system, with no counterpart on the remote.  Network Service will exist on the remote, but it is extremely unlikely that their passwords are the same.  

I resolved this problem by running the service from a custom account I created.  My scenario was with SQL Server, which is probably a little easier to deal with than IIS from a user/permissions context.  The user I created was a local user on both systems, with the same password.  On the target system, I created a share specifically for that user with no other access (NTFS or share).  I then changed the service to log on as this account.  It worked great after that.

You could try to map the drive using PHP's exec() command, but I do not recommend it.  The command would be "net use <drive>: \\server\unc\path <password> /user:<username>".  To remove it, "net use <drive>: /delete".  Remember that these credentials must match a local user on the remote server.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

SameerMirzaAuthor Commented:
what is this net use command, I cant find it.  I belive I will have to use an ad account credentials which has access to both the servers, such as my credentials or any other account (obviously if it works then will change it a generic account etc ..)
0
SameerMirzaAuthor Commented:
ok sory, its a windows command :)
0
SameerMirzaAuthor Commented:
that doesnt work, I have created a share from command line and then tried accessing it from the php and it doesnt see the directory.

So even if I give in a password and create share using exec() command, it would work. Because the share (drive mapping) is specific to the account so I belive Case1, which is creating a custom account and run IIS service using that, bind it with both the servers.

but the problem is that Microsoft discurage that. I remember trying this last time when I wasnt able to run dnscmd command and it didnt work. Could you please provide me with the link/set of instructions that you actually followed for doing - from my understanding it is an AD service accocunt that you are using to run the IIS.
0
Steve BinkCommented:
>>> Because the share (drive mapping) is specific to the account

I'm pretty sure that is the case.  

My scenario involved SQL Server, not IIS, and I completed it only with local accounts.  It may be discouraged, but it worked.  Local account username on server 1, local account username on server 2, both with the same password.

If you have the ability to use AD accounts, then by all means do so - that is what they are for.  My particular situation did not have that possibility.
0
SameerMirzaAuthor Commented:
ok now what I have trid is,
running web site under my own acocunt, which works fine.
I am admin on both servers have access to the drive I have mapped
But still if I run the code from and look for drive C: I and see but not Y: (which is the mapped drive), I have mapped it from command line
I dont know whats going wrong now. I can see the drive, its under my profile, I am runnign the web site with same acocunt then what could be the problem?

Can any please help me out with it?
0
Steve BinkCommented:
IIS does not log on interactively - it logs on as a service.  IIRC, only interactive users get to map a drive, and it exists in the session in which it was created.  On the target server, create a share, give your user the proper NTFS and share rights, and use \\server\sharename from PHP.
0
SameerMirzaAuthor Commented:
ok.
I have created a share on the targer server, for now have set the full control under the same account I am running the web site on the base server.
Calling the share, still doesnt see :/
0
SameerMirzaAuthor Commented:
Please dont give up on this, I realy need to it working

Thanks
0
Steve BinkCommented:
If you log in as the web site user, can you access the share by UNC?
0
gr8gonzoConsultantCommented:
Also check the very last post on this thread:
http://www.webmasterworld.com/forum88/3375.htm
0
Steve BinkCommented:
That is what I was trying to avoid, actually.  :)  My first comments were directing the OP to use a new, custom local account to supplant the normal IUSR/Network Service account used for this type of thing.  I always prefer not to alter the automated account when possible.

If you wanted to get the password to that account (to set up an identical account on the remote server), that is possible with the adsutil.vbs script, usually found in c:\inetpub\adminscripts.  You will have to edit the script to allow for displaying the password, though.
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
SameerMirzaAuthor Commented:
thx
0
Steve BinkCommented:
Is your problem resolved?
0
SameerMirzaAuthor Commented:
yes, I will soon post the solution
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.