简体   繁体   English

具有集成安全性PHP和MS SQL Server的ODBC连接

[英]ODBC Connection with integrated security PHP and MS SQL Server

I need the guidance help on ODBC connection string in PHP, which I am using to connect to MS SQL Server. 我需要有关PHP中的ODBC连接字符串的指导帮助,我正在使用该帮助连接到MS SQL Server。

    <?php
$server = 'UKEMO03'; 
    $database = 'mtpFetch';//the database to connect to
    $user = 'shoabg';// the user has PERMISSIONS AT THE DATABASE
    $pass = 'Shsx12x';//and here the user's password
    $dsn = "Driver={SQL Server};Server=$server;Database=$database;";
    $connect = odbc_connect($dsn, $user, $pass); 
    ?>

Above code works treat, but i have a requirement of not to specify the username and password and use the connection string with Integrated Security. 上面的代码可以用,但是我有一个要求,即不要指定用户名和密码,而是将连接字符串用于Integrated Security。 I can't find anything on internet and I can't change the connection string method because I've completed most of my work and by adapting another connection method will require a massive change in a code in theory its not an option for me. 我无法在Internet上找到任何东西,也无法更改连接字符串方法,因为我已经完成了大部分工作,并且通过改编另一种连接方法将需要对理论上的代码进行大量更改,这对我来说不是一个选择。

Is there a way we can create Integrated Security connection to connect MS SQL Server in PHP using ODBC 有没有一种方法可以创建集成安全性连接以使用ODBC连接PHP中的MS SQL Server

Please help i don't know what to do 请帮助我不知道该怎么办

This will connect you to the ODBC master database (cathalog). 这将使您连接到ODBC主数据库(目录)。 I did not succeed to connect to another database. 我没有成功连接到另一个数据库。 There is an option for default database in the configuration of ODBC SDN, but has no effect ("Chenge the default database to"). 在ODBC SDN的配置中,有一个默认数据库选项,但没有任何作用(“将默认数据库更改为”)。

$this->dbHandle = odbc_connect("Driver={SQL Server};Server=localhost;Integrated Security=SSPI", '', '');

If you use PHP ini make sure you use: 如果您使用PHP ini,请确保使用:

mssql.secure_connection=On

On the database server, make sure you have Windows Authentification associated with your login username 在数据库服务器上,确保您具有与登录用户名关联的Windows身份验证

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM