How do i configure Yii2 to connect to SQLSRV using windows authentication?

519 Views Asked by At

i need to set up a yii2 site to connect to a sql server database which is locked behind windows authentication. normally with sql server auth (essentially username/ password) i'd do it like this.

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'sqlsrv:Server=serverip;Database=dbname',
    'username' => 'dbuser'
    'password' => 'samplePassword',
    'charset' => 'utf8',
    'enableSchemaCache' => true,
];

the server configuration would look something like this i think, but this does not work.(basically the same except using windows login / password, since windows authentication gives access to a windows user and then they can just log in to the SQL server database in SSMS without any additional credentials)

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'sqlsrv:Server=serverip;Database=dbname',
    'username' => 'DOMAIN\windowsusername'
    'password' => 'windowsPassword',
    'charset' => 'utf8',
    'enableSchemaCache' => true,
];

Is this even possible? how would one go about configuring this? ( i can't seem to find any official yii2 docs on this)

0

There are 0 best solutions below