|
@@ -56,6 +56,7 @@ using System.Xml;
|
|
|
#if NET_2_0
|
|
#if NET_2_0
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
#endif
|
|
#endif
|
|
|
|
|
+using System.Security;
|
|
|
|
|
|
|
|
namespace System.Data.SqlClient
|
|
namespace System.Data.SqlClient
|
|
|
{
|
|
{
|
|
@@ -93,6 +94,9 @@ namespace System.Data.SqlClient
|
|
|
// The connection string that identifies this connection
|
|
// The connection string that identifies this connection
|
|
|
string connectionString;
|
|
string connectionString;
|
|
|
|
|
|
|
|
|
|
+ // The connection credentials
|
|
|
|
|
+ SqlCredential credentials;
|
|
|
|
|
+
|
|
|
// The transaction object for the current transaction
|
|
// The transaction object for the current transaction
|
|
|
SqlTransaction transaction;
|
|
SqlTransaction transaction;
|
|
|
|
|
|
|
@@ -133,6 +137,12 @@ namespace System.Data.SqlClient
|
|
|
ConnectionString = connectionString;
|
|
ConnectionString = connectionString;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public SqlConnection (string connectionString, SqlCredential cred)
|
|
|
|
|
+ {
|
|
|
|
|
+ ConnectionString = connectionString;
|
|
|
|
|
+ Credentials = cred;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
#endregion // Constructors
|
|
#endregion // Constructors
|
|
|
|
|
|
|
|
#region Properties
|
|
#region Properties
|
|
@@ -155,6 +165,15 @@ namespace System.Data.SqlClient
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public SqlCredential Credentials {
|
|
|
|
|
+ get {
|
|
|
|
|
+ return credentials;
|
|
|
|
|
+ }
|
|
|
|
|
+ set {
|
|
|
|
|
+ credentials = value;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
#if !NET_2_0
|
|
#if !NET_2_0
|
|
|
[DataSysDescription ("Current connection timeout value, 'Connect Timeout=X' in the ConnectionString.")]
|
|
[DataSysDescription ("Current connection timeout value, 'Connect Timeout=X' in the ConnectionString.")]
|
|
|
#endif
|
|
#endif
|
|
@@ -563,6 +582,16 @@ namespace System.Data.SqlClient
|
|
|
|
|
|
|
|
if (!tds.IsConnected) {
|
|
if (!tds.IsConnected) {
|
|
|
try {
|
|
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);
|
|
tds.Connect (parms);
|
|
|
} catch {
|
|
} catch {
|
|
|
if (pooling)
|
|
if (pooling)
|
|
@@ -879,7 +908,10 @@ namespace System.Data.SqlClient
|
|
|
break;
|
|
break;
|
|
|
case "password" :
|
|
case "password" :
|
|
|
case "pwd" :
|
|
case "pwd" :
|
|
|
- parms.Password = value;
|
|
|
|
|
|
|
+ parms.Password = new SecureString();
|
|
|
|
|
+ foreach (char c in value)
|
|
|
|
|
+ parms.Password.AppendChar(c);
|
|
|
|
|
+ parms.PasswordSet = true;
|
|
|
break;
|
|
break;
|
|
|
case "persistsecurityinfo" :
|
|
case "persistsecurityinfo" :
|
|
|
case "persist security info" :
|
|
case "persist security info" :
|