如果明白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企業管理器,然後在安全性配置中設定。