[Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Login failed for user

801 Views Asked by At

I'm integrating MSSQL Server into my PHP 8.0 application using a Docker container. I've installed the pdo_sqlsrv,sqlsrv and unixodbc extensions, and for that, I've also installed ODBC Driver 18 for the connection. However, I'm encountering the following error:

[Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Login failed for user: 'ZXV\user.name'.

Here's the code for both SQL Server connection methods:

  1. Using SQLSRV Extension:
$serverName = "22.22.22.99,99999"
$connectionInfo = array(
    "UID" => $uid, 
    "PWD" => $pwd, 
    "Database" => $database, 
    "TrustServerCertificate" => true, 
    "Authentication" => "SqlPassword"
);
/* Connect using SQL Server Authentication. */
$conn = sqlsrv_connect($serverName, $connectionInfo);
  1. Using PDO SQLSRV:
$conn = new PDO("sqlsrv:server=$serverName;Database=$database;TrustServerCertificate=true;Authentication=SqlPassword", $uid, $pwd);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

With the same credentials I'm able to connect sql server on my php.5.6 and mssql extension using dblib driver.

Is there any changes on ODBC driver 18 or do I need to add some other configuration

I'm trying to establish database connection with sql server

0

There are 0 best solutions below