PHP无法使用Edge和Windows身份验证在IIS中写入文件

PHP无法使用Edge和Windows身份验证在IIS中写入文件

问题描述:

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.

我在Windows上通过IIS运行PHP,并使用集成身份验证来使用域用户。 p> \ n

以下代码在IE 11,Chrome和Firefox中访问页面时有效。 p>

  $ dir = dirname(__ FILE __); 
 $ dir = realpath  ($ dir。'/ .. / storage / logs'); 
 
 $ filename = $ dir.DIRECTORY_SEPARATOR.'my-log.log'; 
file_put_contents($ filename,'hello world'); 
   pre> 
 
 

在MS Edge中访问时 p>

  PHP警告:file_put_contents(C:\ websites \ my-site \ api \ storage  \ logs \ my-log.log):
无法打开流:第11行的
C:\ websites \ my-site \ api \ public \ permissions.php中的权限被拒绝
  code>  pre> \  n 
 

(它适用于基于Chromium的Edge-Dev,它只是传统/ EdgeHTML版本中存在问题的一个问题。) p>

代码 如果我关闭Windows身份验证,也可以在Edge中运行。 我知道我正在正确输入密码,因为如果我不能从IIS收到401未经授权的邮件。 p>

这个问题不仅仅是我的电脑; 我们尝试过的所有4台笔记本电脑都失败了。 但似乎并不影响服务器,只影响桌面Windows。 p>

更新 strong> p>

根据Deepak-MSFT的建议,我添加了 我的计算机名称是内联网,但它没有改变任何东西。 这个名字就像 laptop-4.example.com code>我添加了http和 *都添加了它.example.com code>已经存在于受信任的站点中,留在或删除 它似乎没有改变任何东西。 p> div>

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.

Auth setting location