简体   繁体   English

使用MSSQL和PHP连接到SQL Server时出错

[英]Error connecting to SQL server with MSSQL and PHP

$myServer = "sql2008";

//$myUser = "zach";
//$myPass = "pass";

//$myUser = "DOMAIN/zach";
//$myPass = "pass";

//$myUser = "zach@DOMAIN.net";
//$myPass = "pass";

$myUser = "sa";
$myPass = "pass";


$myDB = "Database"; 

//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer. Error: " . mssql_get_last_message());

So what i have noticed is that i can connect with SA (server admin) but i can not connect with my user name, which is a domain user that has a lot of permissions. 因此,我注意到的是,我可以与SA(服务器管理员)连接,但无法与我的用户名连接,该用户名是具有很多权限的域用户。

the only one that is giving me an error message is when the username is zach@DOMAIN.net. 唯一的一条错误消息是用户名zach@DOMAIN.net。

Couldn't connect to SQL Server on sql2008. Error: Login failed for user 'zach@DOMAIN.net'.

that leads me to believe that there must be some setting on the server that allows for logins, but i dont know where to look. 这使我相信服务器上必须存在一些允许登录的设置,但是我不知道在哪里查找。

* UPDATE * ** * * 更新 * ** *

So after looking in SQL Server Management Studio, I realized that it accepts logins from the sysadmin server roles group. 因此,在查看SQL Server Management Studio之后,我意识到它接受sysadmin服务器角色组的登录。 So i added my AD account to the group, but i was still not able to connect with my user name. 因此,我将我的AD帐户添加到该组中,但是仍然无法使用我的用户名进行连接。 i used they three approaches i listed above. 我使用了上面列出的三种方法。 is there a fourth option? 还有第四种选择吗?

That being said, is there a way that i can tell it to connect to a group not sysadmin? 话虽这么说,有没有办法我可以告诉它连接到不是sysadmin的组? for security reason i would prefer not to connect to sysadmin? 出于安全原因,我宁愿不连接到sysadmin?

Go to login account properties, there's must be some tab there about status that has grant and deny option... I don't have SQL in this PC. 转到登录帐户属性,那里必须有一些关于具有授予和拒绝选项的状态的选项卡...我在这台PC上没有SQL。 It looks something like this: 看起来像这样:

http://www.google.com.ph/imgres?q=sql+login+grant&um=1&hl=tl&client=firefox-a&hs=tvs&sa=N&rls=org.mozilla:en-US:official&biw=1366&bih=602&tbm=isch&tbnid=LMuu3zBDlLIn5M:&imgrefurl=http://kb.bizagi.com/Goto50061.aspx&docid=P4HAWWO6mFEFMM&imgurl=http://kb.bizagi.com/Uploads/Images/SQL%2525204.jpg&w=709&h=630&ei=nB63TteSBqWriAexnszxDA&zoom=1&iact=hc&vpx=360&vpy=292&dur=1302&hovh=212&hovw=238&tx=161&ty=115&sig=103098649454558437088&page=1&tbnh=129&tbnw=146&start=0&ndsp=21&ved=1t:429,r:15,s:0 http://www.google.com.ph/imgres?q=sql+login+grant&um=1&hl=tl&client=firefox-a&hs=tvs&sa=N&rls=org.mozilla:zh-CN:official&biw=1366&bih=602&tbm=isch&tbnid= LMuu3zBDlLIn5M:&imgrefurl = http://kb.bizagi.com/Goto50061.aspx&docid=P4HAWWO6mFEFMM&imgurl=http://kb.bizagi.com/Uploads/Images/SQL%2525204.jpg&w=709&h=630&h=z&px=z&px=px&px= 360&vpy = 292&dur = 1302&hovh = 212&hovw = 238&tx = 161&ty = 115&sig = 103098649454558437088&page = 1&tbnh = 129&tbnw = 146&start = 0&ndsp = 21&ved = 1t:429,r:15,s:0

I'm not into Active Directory that much but I have tried adding a DOMAIN/GROUP to login account in SQL server. 我不太喜欢Active Directory,但是我尝试将DOMAIN/GROUP添加到SQL Server中的登录帐户。 Look at this post, it teaches how to add a login for a group in a domain. 看看这篇文章,它教导了如何为域中的组添加登录信息。 How to add Active Directory user group as login in SQL Server 如何在SQL Server中将Active Directory用户组添加为登录名

The solution that I found was SQL Server did not like the fact that I was trying to use a domain account. 我发现的解决方案是SQL Server不喜欢我尝试使用域帐户的事实。 I realized that any SQL user account that i created works fine, it is just when I try to use AD accounts it doesn't work. 我意识到,我创建的任何SQL用户帐户都可以正常使用,只是当我尝试使用AD帐户时,它无法正常工作。

I am sure that some people will want to use AD, but i don't need it in this situation. 我确信有些人会想要使用AD,但是在这种情况下我不需要它。

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

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