http://topic.csdn.net/t/20020422/09/665662.htmlSecurity Support Provider InterfaceThe Security Support Provider Interface (SSPI) allows an application to use any of the various security models available on a computer or network without changing the interface to the security system. SSPI does not establish credentials (logon), because that is generally a privileged operation handled by the operating system.
A security provider is a dynamic-link library that implements the Security Support Provider Interface to make one or more security packages available to applications. Each security package provides the necessary mapping between the SSPI and the actual security model, such as Kerberos or Microsoft LAN Manager.
An application can use the package management functions to list the security packages available and select one to support its needs. The application then uses the credential management functions to obtain a handle to the credentials of the user on whose behalf they are executing. With this handle, the application can use the context management functions to create a security context to a service. A security context is an opaque data structure that contains the security data relevant to a connection, such as a session key, the duration of the session, and so on. Finally, the application uses the security context with the message support functions to ensure message integrity and privacy during the connection.
A security provider is a dynamic-link library that implements the Security Support Provider Interface to make one or more security packages available to applications. Each security package provides the necessary mapping between the SSPI and the actual security model, such as Kerberos or Microsoft LAN Manager.
An application can use the package management functions to list the security packages available and select one to support its needs. The application then uses the credential management functions to obtain a handle to the credentials of the user on whose behalf they are executing. With this handle, the application can use the context management functions to create a security context to a service. A security context is an opaque data structure that contains the security data relevant to a connection, such as a session key, the duration of the session, and so on. Finally, the application uses the security context with the message support functions to ensure message integrity and privacy during the connection.
System.Data.SqlClient.SqlConnection
常用的一些连接字符串(C#代码):SqlConnection conn = new SqlConnection( “Server=(local);Integrated Security=SSPI;database=Pubs“);SqlConnection conn = new SqlConnection(“server=(local)\NetSDK;database=pubs;Integrated Security=SSPI“);SqlConnection conn = new SqlConnection(“Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;“);SqlConnection conn = new SqlConnection(“ data source=(local);initial catalog=xr;integrated security=SSPI;
persist security info=False;workstation id=XURUI;packet size=4096; “);SqlConnection myConn = new System.Data.SqlClient.SqlConnection(“Persist Security Info=False;Integrated
Security=SSPI;database=northwind;server=mySQLServer“);SqlConnection conn = new SqlConnection( “ uid=sa;pwd=passwords;initial catalog=pubs;data source=127.0.0.1;Connect Timeout=900“);更多字符串连接说明请看MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlConnectionClassConnectionStringTopic.asp
Integrated Security=SSPI是指连接数据库时用信任连接,也就是数据库里面通常所说的windows登陆
如果你在程序里面提供用户名及密码,也就是用户帐户登陆模式就不需要写上面的语句了
cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" & _
"Data Source=" & Trim(txtServer.Text) & ";Initial Catalog=" & master & _
";uid=" & Trim(txtUser.Text) & ";pwd=" & Trim(txtPwd.Text)
Initial Catalog所在命名空间:system.data.sqlclient
两者不在一个命名空间无法同时出现在同一字符串中
如果连接oledb数据源用oledb,如果连接sql数据源用sqlclient
lz的写法可以
不过要注意连接的数据源