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 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化