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 ^_^)