I have a requirement to connect to a local SQL Server using PHP and Windows Authentication (specifying a username and password is not an option; it must be via Windows Authentication only).
Here is the connection string as per the Microsoft examples:
try {
$conn = new PDO( "sqlsrv:Server=(local)\SQLEXPRESS;Database=accounting;ConnectionPooling=0", NULL, NULL);
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
}
Here is the error message that I am receiving:
PDOException: SQLSTATE[28000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'DOMAIN\server$'. in ...
However I had already added this computer to the access on the SQL Server using these commands:
CREATE LOGIN [DOMAIN\server$] FROM WINDOWS;
GO
USE accounting;
GO
CREATE USER [DOMAIN\server$] FROM LOGIN [DOMAIN\server$];
GO
What else could be the issue?