I'm trying to connect to a Microsoft SQL Server database through Windows Authentication using the following code:
<?php $serverName = "sql"; $options = array("Database" => "sql"); $conn = sqlsrv_connect($serverName, $options); if($conn == false) { die(print_r(sqlsrv_errors())); } ?>
It uses Microsoft's SQL Server Driver for PHP. As written above, the web server is trying to connect to the database using Windows Authentication. However, the following error is returned:
[Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'DOMAIN\JOHNDOE$'.
The problem seems to be that a connection is trying to be made as the user "DOMAIN\JOHNDOE$" which is the machine name. Rather, the correct log-in (when I do it through Studio Manager) is "DOMAIN\john.doe". After doing some research, this seems to be caused because "By default, the SQL Server Driver for PHP uses Windows Authentication to connect to SQL Server. It is important to notice that in most scenarios, this means that the Web server's process identity or thread identity (if the Web server is using impersonation) is used to connect to the server, not an end-user's identity."
How do I ensure that the correct log-in credentials are used? Please note that I cannot consider using SQL Server Authentication and that the solution must work when the app is distributed to other end-users, so I won't make heavy personal modifications to my computer.
Thank you!