Trouble Opening Shared Files Over Local Intranet...

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Trouble Opening Shared Files Over Local Intranet...

Postby sbennett » 07. August 2020 21:57

Stuck on developing a local intranet for a client's small business enterprise network.

OS: Windows 2019 Database Server

Active Directory: Accessed through LDAPS

Web Server: XAMPP v3.2.4

Web Server Language: PHP

Hosting Machine: HOST (virtual server)

Goals:

1) Provide an "Employee Center" where all the employee and company data can be found in a single place. Apache and MySQL are working to maintain company data provided by employees and admins. Users can access these features from their local machines, when they click the hyperlink and log into the intranet.

2) Provide access to their company's shared drives, through the intranet. PHP accomplishes this by running the file access command through the command line. This is where we are getting STUCK. When the user uses the intranet to select a file from a shared drive, and open it, the file is opening in the HOST machine, where the Apache server is running, and not the user's local machine!

Let me tell you, it was weird watching random files open up while I was working on the HOST. I thought we'd been hacked! Then a co-worker called, wanting to know why their desired files weren't showing up when they tried to access them on the intranet, from their local machine.

Since the virtual HOST server is where the Apache web server is running the show, I assume that Apache is reflexively opening the desired file (from a shared drive) on it's own server. The hyper link we are using is connecting the user to the intranet, but the web server is opening files on the HOST, rather than sending the "open file" commands back to the user's local machine.

My question is, is there a way to qualify the Command Line request so that the desired file is opened on a specific machine or (better yet) for a specific user? I have access to the active directory to identify a current user and their current machine, for example.

I'm currently accessing shared network files by creating, running and closing a scheduled task. This is the code PHP is currently running through the command line. It works on the HOST machine, but continues to fire on the HOST machine, even if the user is logged in from their local machine.

Note: "$escapedLogPath" is the path to the user's desired file.

Create the task:

SCHTASKS /F /Create /TN MyTasks_notepad /TR "\\'.$escapedLogPath.'\\" /SC DAILY /RU INTERACTIVE

Run the task:

SCHTASKS /RUN /TN "MyTasks_notepad"

Delete the task:

SCHTASKS /DELETE /TN "MyTasks_notepad" /F

This code works if launched while logged into the HOST, opening the file right on the HOST, but when the user logs in from their local machine, the desired file path is still activated on Apache's HOST machine. It's not opening on the user's local machine.

Can this be accomplished by modifying the above commands?

If PHP is not an option, could this accomplished in a batch file? With arguments fed to it by PHP calling up the command line?

Another option could be that the client handles most of their business on their local IIS server. I could probably migrate the intranet from Apache to IIS, but I haven't worked with IIS much and want to know for sure that IIS can meet our intranet goals, before configuring IIS for PHP and migrating the entire intranet over.

Any advice, links to tutorials or guidance would be greatly appreciated.

I've build online websites before, but inter-connecting shared drives over a local intranet is way more complicated than that!
sbennett
 
Posts: 3
Joined: 06. August 2020 16:48
XAMPP version: 3.2.4
Operating System: Windows Server 2019 Datacenter

Re: Trouble Opening Shared Files Over Local Intranet...

Postby gsmith » 10. August 2020 20:58

per http://httpd.apache.org/docs/2.4/platfo ... tml#winsvc

By default, all Apache services are registered to run as the system user (the LocalSystem account). The LocalSystem account has no privileges to your network via any Windows-secured mechanism, including the file system, named pipes, DCOM, or secure RPC. It has, however, wide privileges locally.

Never grant any network privileges to the LocalSystem account! If you need Apache to be able to access network resources, create a separate account for Apache as noted below.

It is recommended that users create a separate account for running Apache service(s). If you have to access network resources via Apache, this is required.


That link explains what you'll need to do.
gsmith
 
Posts: 268
Joined: 29. November 2013 18:04
Location: San Diego
XAMPP version: 0.0.0
Operating System: Win 10/2012R VS 14,15,16

Re: Trouble Opening Shared Files Over Local Intranet...

Postby sbennett » 11. August 2020 16:28

Thanks so much, I'll dig into it right away :)
sbennett
 
Posts: 3
Joined: 06. August 2020 16:48
XAMPP version: 3.2.4
Operating System: Windows Server 2019 Datacenter

Re: Trouble Opening Shared Files Over Local Intranet...

Postby sbennett » 13. August 2020 23:55

So, I'm running Apache as a window's service. Check.
It's logging is as an account with administrator privileges, so it shouldn't have problems opening files. Check.

I've added an alias for a shared network drive (in httpd.conf and httpd-vhosts.conf): Check, Check.

Alias "/TestDrive/" "//server01/TestDrive/"
<Directory "//server01/TestDrive/">
Options Indexes
</Directory>

I've also added a file within that drive (test.txt) to find / open for testing purposes.

When I use the intranet from the Host Server (where the Apache Server is running), I can navigate through the shared drives and open those files without issue.

When it comes to opening the file, attempts to use a simple "open file" command through PHP's "shell_exec" usually result in no response at all, which is difficult to de-bug.

The only method I've found to reliably open files (such as opening a text file in notepad) is through the "SCHTASKS " function on the command line, which I use through PHP's "shell_exec" command to create the "open file" task, run the task and delete the task when it's done.

Now, the user on Server_B can log into this intranet from their machine. They can access the website's pages and even scroll through the contents of shared drives, but when they try to open a file, the "SCHTASKS" command is running from the Apache's Host Server, so the file opens on there, not on Server_B, where the user is logging in from.

I'm trying variations of the "SCHTASKS" commands to try and add tasks to the user's Server_B from the Host Server, which is triggering a number of path or credential errors.

For Example: "SCHTASKS /S Server_B /Create /RL HIGHEST /SC DAILY /TN MyTasks\_notepad /TR "\\server01\TestDrive\test.txt\""

If the intranet is running from the Host Server, and every action the server takes in PHP is through the Host Server, how can it possibly open files on the user's Server B?

I've been at this for days and the boss will want an update soon, but I'm just stuck. Maybe I'm just missing some key syntax on the command, or some additional configuration for Apache. Any ideas?
sbennett
 
Posts: 3
Joined: 06. August 2020 16:48
XAMPP version: 3.2.4
Operating System: Windows Server 2019 Datacenter


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 100 guests