数据库+ Windows身份验证+用户名/密码? [英] Database + Windows Authentication + Username/Password?

查看:221
本文介绍了数据库+ Windows身份验证+用户名/密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直认为,为了使用具有明确指定凭据的Windows身份验证连接到SQL服务器,您必须LogonUser的,冒充,然后连接。

在我看来,那<一个href=\"http://blogs.msdn.com/spike/archive/2008/11/14/connectionstrings-mixing-usernames-and-windows-authentication-who-goes-first.aspx\">this链接表明,它可以连接到SQL服务器,而这一切的麻烦,只需通过指定的uid = ...; PWD = ...,在连接字符串。我测试了这种方法只是为了确保它不工作,和 - 你瞧 - 它没有。如果该博客文章并不在msdn.com,我刚才驳回它作为小白谈话,但它是。

有没有人有一个想法,我缺少的是什么?

EDIT1:许多受访者误解了我指的是。下面是我在谈论的复制/粘贴。它的的集成SQL,也不是由IIS做出了ASP.NET模拟:

 字符串sql4 =的String.Format(
   @数据源= {0};集成安全性= SSPI; UID =&LT; UID取代; PWD =&LT; PID&gt;中,服务器);
//数据库+ Windows身份验证+用户名/密码


解决方案

有两种不同类型的安全性与SQL Server。 Windows身份验证和SQL Server身份验证。当你看到的uid和pwd你看到了后者。在这种情况下,uid是不是Windows主体 - 操作系统对此一无所知

所以回答你的问题是,,则无法连接字符串登录到SQL Server中的传递Windows用户名和密码。

I have always thought that in order to connect to SQL server using windows authentication with explicitly specified credentials, you must LogonUser, Impersonate, then connect.

It seems to me that this link suggests that it's possible to connect to SQL server without all this hassle, simply by specifying "uid=...;pwd=..." in connection string. I tested this method just to be sure it doesn't work, and - lo and behold - it didn't. If that blog post wasn't on msdn.com, I would have just dismissed it as noob talk, but it is.

Does anyone have an idea what am I missing?

EDIT1: Many respondents misunderstood what I was referring to. Here's a copy/paste of what I was talking about. It's not integrated SQL, nor it's an ASP.NET impersonation made by IIS:

string sql4 = String.Format(
   @"Data Source={0};Integrated Security=SSPI;uid=<uid>;pwd=<pid>", server);     
// Database + Windows Authentication + Username/Password

解决方案

There are two distinct kinds of security with SQL Server. "Windows Authentication", and "SQL Server Authentication". When you see uid and pwd you're seeing the latter. The uid in this case is not a Windows principal - the OS knows nothing about it.

So the answer to your question is, no, you can't pass Windows user name and password in the connection string to log in to SQL Server.

这篇关于数据库+ Windows身份验证+用户名/密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆