转至繁体中文版     | 网站首页 | 文章中心 | 下载中心 | 图片中心 | 笑话频道 | 教程频道 | 会员中心 | 雁过留声 | 
最新公告:     "MinTao学以致用网"欢迎您的光临,你的支持便是我们的动力,欢迎广大网友和各界人士亲临指导,你们的一个小小的建议便是我们发展的开路石!  [MinTao  2007年9月5日]        
您现在的位置: MinTao学以致用网 >> 文章中心 >> 电子课堂 >> 数据库 >> Sql Server >> 文章正文
专题栏目
更多内容
最新推荐 更多内容
相关文章
通过HTTP访问SQL Server
SQL Server 7.0数据库的
VB应用程序访问SQL Serv
将DBF数据库转换成SQL S
拷贝的SQL Server 7数据
如何使用SQL Server客户
使用SQL Server 2000将现
在Linux下访问MS SQL Se
影响SQL server性能的关
Microsoft SQL Server 7
更多内容
理解SQL Server 2000的信任连接(Trusted connection)         
理解SQL Server 2000的信任连接(Trusted connection)
作者:yjgx007 文章来源:不详 点击数: 更新时间:2007-11-14 12:56:57

我在用OLEDB方式连接SQL Server时, 用到连接字: "provider=SQLOLEDB.1;data source=localhost;initial catalog=WroxBooks; Trusted_Connection=yes; User ID=sa;Password=;"
调用后一直无法正常连接。

ASP.NET错误描述:
* Error while accessing data.
用户 ''''CXY\ASPNET'''' 登录失败。

ASP错误描述:
Microsoft OLE DB Provider for SQL Server (0x80040E4D)
用户 ''''CXY\IUSR_CXY'''' 登录失败。

已确信所连接的数据源,帐号和口令都是正确的,根据出错描述,怎么连接会用

CXY\ASPNET或CXY\IUSR_CXY登录?(我已明确指定User ID=sa;Password=;),经过多

次试验,最后将连接字中的Trusted_Connection=yes;删除,连接成功!

如果明白SQL Server登录验证的原理, 就可以知道Trusted Connection的含义。
在SQL Server Architecture(SQL Server架构)登录篇中有关于Authenticating Logins(登录验证)的讲述, 摘录如下:

......

SQL Server 2000 uses two types of authentication: Windows Authentication

and SQL Server Authentication.

......

When using Windows Authentication, you do not have to specify a login ID

or password when you connect to SQL Server 2000. Your access to SQL

Server 2000 is controlled by your Windows NT or Windows 2000 account or

group, which is authenticated when you log on to the Windows operating

system on the client.

When you connect, the SQL Server 2000 client software requests a Windows

trusted connection to SQL Server 2000. Windows does not open a trusted

connection unless the client has logged on successfully using a valid

Windows account. The properties of a trusted connection include the

Windows NT and Windows 2000 group and user accounts of the client that

opened the connection. SQL Server 2000 gets the user account information

from the trusted connection properties and matches them against the

Windows accounts defined as valid SQL Server 2000 logins. If SQL Server

2000 finds a match, it accepts the connection. When you connect to SQL

Server 2000 using Windows 2000 Authentication, your identification is

your Windows NT or Windows 2000 group or user account.

SQL Server 2000采用两种不同的验证方式:Windows验证和SQL Server 2000验证

用Windows验证连接时,不必指定一个用户ID及口令,连接验证使用Windows NT或2000的组帐号(group account)。
要知道:SQL Server 2000 在连接验证之前,用户先用Windows NT或2000的组帐号在客户端成功登录至SQL Server 2000服务器,方能建立一个信任连接(Trusted connection),SQL Server从信任连接属性中获取用户的帐号信息,将其与Windows已定义的帐号信息匹配和分析,如果正确就连接成功,并将此Windows帐号作为连接至SQL Server 2000的用户ID。

上文中的连接字中包含有:Trusted_Connection=yes;
这就意味着连接将采用信任连接方式,但由于连接前没有用Windows组帐号(在ASP环境中是访问IIS服务帐号IUSR_计算机名,在ASP.NET环境中帐号是ASPNET)登录至SQL Server 2000服务器, 也就是说没有建立一个信任连接(Trusted connection),当然,SQL Server 2000连接也不能够成功。

将Trusted_Connection=yes;删除或改为Trusted_Connection=no;
这将不采用信任连接方式(也即不采用Windows验证方式),而改由SQL Server 2000验证方式,即在连接字中指定:User ID=user name;Password=user password;
SQL Server 2000会将此用户ID和口令进行验证连接,而与Windows帐号无关。

关于SQL Server 2000上述两种验证方式的设置(连接验证采用Windows和SQL Server验证,还是仅采用Windows验证),可以启动SQL Server 2000企业管理器,然后在安全性配置中设置。

文章录入:mintao    责任编辑:mintao 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007 MinTao学以致用网(www.mintao.net) Inc All Rights Reserved.
    QQ:543098146有事请Q我! QQ:261561092有事请Q我 QQ:179647303有事请Q我 MSN:min906@126.com
    站长:MinTao 信息产业部ICP备案号:鄂ICP备07500065号

    学以致用是我们学习者的至高境界和不懈追求,[MinTao学以致用网]与大家共同学习,共同进步……
    信息产业部备案
    *鄂ICP备07500065号