Connecting to SQL Server using windows authentication

Do you have questions regarding other database enginges (not MySQL) -- ask here!

Moderators: egami, macek, gesf

Post Reply
arichins
New php-forum User
New php-forum User
Posts: 4
Joined: Wed Nov 22, 2017 10:04 am

Wed Nov 22, 2017 4:33 pm

Hey, I'm brand new to PHP, and to get my feet wet, I just wanted to make a form that writes a record to a database (sql server 2014).

I read that if you don't specify a username or password, PHP will use windows authentication by default. But it will use the credentials of the identity of the app pool that is running the php application.

So I made an app pool, and set it to run under the identity of an active directory user (this user is used to connect to the same DB for other processes).

But when I run the form, I get a connection error. It looks like the PHP engine is trying to connect to the database as an anonymous user rather than with the application pool identity.

Has anyone out there set this up?

[SQLSTATE] => 28000 [1] => 18456

Code: Select all

 => 18456 [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. ) [1] => Array ( [0] => 28000
 
 
        $serverName = "trans";
        $connectionInfo = array("Database"=>"transdb");        
        $conn = sqlsrv_connect($serverName,$connectionInfo);

Post Reply