PHP PDO连接到具有集成安全性的SQL Server? [英] PHP PDO Connection to SQL Server with integrated security?
问题描述
我可以使用PDO连接到SQL Server 2008并使用mssql驱动程序来集成安全性吗?当前正在执行以下操作以正常连接:
Can I connect to SQL Server 2008 using PDO and integrated security using the mssql driver? Currently doing something like this to connect normally:
$db = new PDO("mssql:host=host;dbname=db", "user", "pass");
使用SQL Server身份验证可以很好地工作,但是必须为数据库负载创建SQL Server登录名很麻烦,因此,如果可能的话,最好使用集成安全性.我正在Windows上以CLI的形式运行PHP.
This works fine using SQL Server authentication, but it is a pain having to create SQL server logins for loads of databases, so it would be nice to use integrated security if possible. I am running PHP as CLI on Windows.
推荐答案
该网站帮助: 用于PHP的SQL Server驱动程序:了解Windows身份验证
解决我的问题的要点是:
The gist of it that fixed my issue was:
- 启用Windows身份验证
- 禁用匿名身份验证
- 从PDO连接中删除用户名和密码
$conn = new PDO( "sqlsrv:server=$serverName ; Database=$dbName" );
我的测试是使用2010年6月发布的最新驱动程序(用于PHP 2.0 CTP2的SQL Server驱动程序)进行的.
My testing was with the newest driver released June 2010 (SQL Server Driver for PHP 2.0 CTP2).
这篇关于PHP PDO连接到具有集成安全性的SQL Server?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!