#if NET_2_0
using System.Collections.Generic;
#endif
+using System.Security;
namespace System.Data.SqlClient
{
// The connection string that identifies this connection
string connectionString;
+ // The connection credentials
+ SqlCredential credentials;
+
// The transaction object for the current transaction
SqlTransaction transaction;
ConnectionString = connectionString;
}
+ public SqlConnection (string connectionString, SqlCredential cred)
+ {
+ ConnectionString = connectionString;
+ Credentials = cred;
+ }
+
#endregion // Constructors
#region Properties
}
}
+ public SqlCredential Credentials {
+ get {
+ return credentials;
+ }
+ set {
+ credentials = value;
+ }
+ }
+
#if !NET_2_0
[DataSysDescription ("Current connection timeout value, 'Connect Timeout=X' in the ConnectionString.")]
#endif
if (!tds.IsConnected) {
try {
+ if (Credentials != null) {
+ if (parms.User != String.Empty)
+ throw new ArgumentException("UserID already specified");
+ if (parms.PasswordSet)
+ throw new ArgumentException("Password already specified");
+ if (parms.DomainLogin != false)
+ throw new ArgumentException("Cannot use credentials with DomainLogin");
+ parms.User = Credentials.UserId;
+ parms.Password = Credentials.Password;
+ }
tds.Connect (parms);
} catch {
if (pooling)
break;
case "password" :
case "pwd" :
- parms.Password = value;
+ parms.Password = new SecureString();
+ foreach (char c in value)
+ parms.Password.AppendChar(c);
+ parms.PasswordSet = true;
break;
case "persistsecurityinfo" :
case "persist security info" :