Error connecting to SQL server with MSSQL and PHP

2019-09-16 19:25发布

$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.

the only one that is giving me an error message is when the username is 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. So i added my AD account to the group, but i was still not able to connect with my user name. 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? for security reason i would prefer not to connect to sysadmin?

2条回答
SAY GOODBYE
2楼-- · 2019-09-16 20:02

The solution that I found was SQL Server did not like the fact that I was trying to use a domain account. 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.

I am sure that some people will want to use AD, but i don't need it in this situation.

查看更多
倾城 Initia
3楼-- · 2019-09-16 20:04
登录 后发表回答