mirror of
https://github.com/silverstripe/silverstripe-mssql
synced 2024-10-22 08:05:53 +02:00
ENHANCEMENT Support for Windows authentication for MSSQLDatabase - this is a more secure way of connecting to the database server, because a username and password is not required in the _ss_environment.php file
This commit is contained in:
parent
e4fe94aae3
commit
7e45cfda78
@ -87,10 +87,16 @@ class MSSQLDatabase extends SS_Database {
|
|||||||
if($this->mssql) {
|
if($this->mssql) {
|
||||||
$this->dbConn = mssql_connect($parameters['server'], $parameters['username'], $parameters['password'], true);
|
$this->dbConn = mssql_connect($parameters['server'], $parameters['username'], $parameters['password'], true);
|
||||||
} else {
|
} else {
|
||||||
$this->dbConn = sqlsrv_connect($parameters['server'], array(
|
// Windows authentication doesn't require a username and password
|
||||||
'UID' => $parameters['username'],
|
if(defined('MSSQL_USE_WINDOWS_AUTHENTICATION') && MSSQL_USE_WINDOWS_AUTHENTICATION == true) {
|
||||||
'PWD' => $parameters['password'],
|
$connectionInfo = array();
|
||||||
));
|
} else {
|
||||||
|
$connectionInfo = array(
|
||||||
|
'UID' => $parameters['username'],
|
||||||
|
'PWD' => $parameters['password'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$this->dbConn = sqlsrv_connect($parameters['server'], $connectionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->dbConn) {
|
if(!$this->dbConn) {
|
||||||
|
Loading…
Reference in New Issue
Block a user