dongshu4221 2019-06-14 14:05
浏览 156
已采纳

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.

  • 写回答

1条回答 默认 最新

  • douyi2664 2019-06-26 15:32
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 全志H618ROM新增分区
  • ¥20 jupyter保存图像功能的实现
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况