Strange behaviour - differences between http://localhost and http://servername/ (on IIS)
-
Friday, January 14, 2011 8:57 AM
Hello together,
the SQL Server Driver for PHP drives me crazy. I've got a Windows Server 2003 and a IIS6.0 running on it.
My Server connects to a SQL Server 2005. I've got the Native Client 2008 installed on my IIS Server. I connect to the server via sqlsrv_connect('SERVERNAME',array('DB'=>'mygreatdb'));
The code should use the worker process domain account to connect to the sql server. This works actually, but only when I'm on the IIS server via Remotedesktop and open the webpage as http://localhost/.
When I open the page on my client computer via http://servername/ I'm getting the following sqlsrv_error Array:
Array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. ) [1] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. ) )I don't know why this happens. It's so strange. I tried to find a configuration tool for the native client or some configuration option in the driver for php, but I couldn't find anything.
I'd be very happy if anyone could help me somehow to fix this error.
Greetings
-Thomas
All Replies
-
Friday, January 14, 2011 1:39 PM
Hi Thomas
This isn't the driver's fault.
An easy way to fix this is to use SQL Server user name and password to connect, instead of trusted NT credentials . If you want to use NT login, read the rest..
It is a combination of IIS and fastCGI (which has flag fastcgi.impersonate in php.ini).
Try setting:
fastcgi.impersonate=0
in php.ini.
If you're not using fastcgi, let me know...!
Rob- Marked As Answer by Ashay Chaudhary [MSFT]Moderator Sunday, January 16, 2011 4:25 PM
-
Friday, January 14, 2011 3:55 PMModerator
I've run into this problem too and wrote a blog post about it: http://blogs.msdn.com/b/brian_swan/archive/2010/02/10/sql-server-driver-for-php-understanding-windows-authentication.aspx
That post just adds to Robert's suggestion.
-Brian
This posting is provided "AS IS" with no warranties, and confers no rights. http://blogs.msdn.com/brian_swan- Marked As Answer by Ashay Chaudhary [MSFT]Moderator Sunday, January 16, 2011 4:25 PM
-
Wednesday, August 01, 2012 2:58 PM
Thanks Robert,
It work perfectly for me.

