简体   繁体   中英

PHP can't write files in IIS using Edge and Windows Authentication

I am running PHP through IIS on windows, and using the Integrated Authentication for using domain users.

The following code works when accessing a page in IE 11, Chrome and Firefox.

$dir = dirname(__FILE__);
$dir = realpath($dir.'/../storage/logs');

$filename = $dir.DIRECTORY_SEPARATOR.'my-log.log';
file_put_contents($filename, 'hello world');

When accessed in MS Edge

PHP Warning: file_put_contents(C:\websites\my-site\api\storage\logs\my-log.log): 
failed to open stream: Permission denied in 
C:\websites\my-site\api\public\permissions.php on line 11 

(It works in the Edge-Dev that is based on Chromium, it is only a problem in the traditional / EdgeHTML version that has the problem.)

The code works in Edge too if I turn off the windows authentication. I know that I am typing my password correctly because if I don't I get a 401 unauthorised message from IIS.

This issue is not just my computer; it has failed on all 4 laptops we've tried it on. But does not seem to affect servers, only desktop Windows.

Update

As per Deepak-MSFT's suggestion I added my computer's name to the intranet, but it didn't change anything. The name is like laptop-4.example.com I added it both with and without http and *.example.com was already in trusted sites, leaving it in or removing it does not seem to change anything.

It appears that for some reason Edge seems to prefer having NTLM before Negotiate in the list. Don't know why, but it has solved the problem. I can reliably revert back to Negotiate to cause the issues again, so its pretty likely to be the cause.

验证设置位置

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM