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 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据