Apache and PHP on Windows: access to a network directory using another user instead “Local System”

I have a Windows Server 2019 running web server Apache 2.4 PHP8 with user “Local System”. This server is not in a Domain and I want to mantain the user “Local System” which executes the services for security reasons.
In a PHP script I want to execute scandir to a network folder “srv-datadocuments” and I want to configure Apache to use another user to access this folder.
Then:

  1. I create the file .htpasswd with username “user.data” and relative password
  2. I add these line into the apache configuration file:
<Directory "\srv-datadocuments">
  AuthType Basic
  AuthName "Access only allowed for user.data"
  AuthUserFile .htpasswd
  Require user user.data
</Directory>
  1. I restart the service.

If I try to execute the PHP script, the web server still returns “access is denied (code 5)”.

The user credentials are stored into the Windows Server 2019 and the destination server and if I try to access with file explorer with “user.data” user it works, then I think it is a bad configuration on apache configuration file
Thank for you help

Best regards

Matteo

I tried to add some double quotes to reference the .htpasswd files, I tried to change something else to the configuration but it still not works.
The web server must continue to be run by the “Local Server” user and the same web server must access to the directory “srv-datadocuments” with the different user “user.data”