doukuanghuan7582 2015-02-11 10:11
浏览 56
已采纳

使用Windows身份验证的PHP计划任务

I am working on an PHP application hosted on Windows Server 2008. Sorry if some informations are not clear but this work has been made by another developer and I can not contact him.

There is a scheduled task executed every week to synchronize some data from a SQL Server database on another server (I do not have access to this other server).

The scheduled task runs a .bat file :

start C:\...\php.exe E:\...\synchro.php

But the script cannot connect to the database :

[Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

When I run my PHP script from command line, like this :

php E:\...\synchro.php

... everything is working.

In my synchro.php file, the connection to the database is made like this :

$connectionInfo = array('Database'=> $database);
$conn = sqlsrv_connect($serverName, $connectionInfo);

I think it is using Windows Authentication because there is no login/password.

In the scheduled task properties, the following options are checked :

  • "Run whether user is logged on or not"
  • "Do not store password. The task will only have to access to local computer resources."

And in "When running the task, use the following user account" there is the current account.

I don't understand why it works when running the PHP script in command line but not from the scheduled task.

Do you have any idea ?

Thanks in advance (and sorry if my English is not perfect ^_^)

  • 写回答

1条回答 默认 最新

  • dtll2016 2015-02-13 15:40
    关注

    I resolved the problem :

    In the tasks properties, the option "Do not store password" was checked. Without this option, everything works.

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

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题