Imported Upstream version 3.12.0

Former-commit-id: cf92446697332992ec36726e78eb8703e1f259d7
This commit is contained in:
Jo Shields
2015-01-13 10:44:36 +00:00
parent 8b9b85e7f5
commit 181b81b4a4
659 changed files with 12743 additions and 16300 deletions

View File

@@ -56,6 +56,7 @@ using System.Xml;
#if NET_2_0
using System.Collections.Generic;
#endif
using System.Security;
namespace System.Data.SqlClient
{
@@ -93,6 +94,9 @@ 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;
@@ -133,6 +137,12 @@ namespace System.Data.SqlClient
ConnectionString = connectionString;
}
public SqlConnection (string connectionString, SqlCredential cred)
{
ConnectionString = connectionString;
Credentials = cred;
}
#endregion // Constructors
#region Properties
@@ -155,6 +165,15 @@ namespace System.Data.SqlClient
}
}
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
@@ -563,6 +582,16 @@ namespace System.Data.SqlClient
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)
@@ -879,7 +908,10 @@ namespace System.Data.SqlClient
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" :

View File

@@ -0,0 +1,76 @@
//
// System.Data.SqlClient.SqlCredential.cs
//
// Author:
// Neale Ferguson (neale@sinenomine.net)
//
// Copyright (C) Neale Ferguson, 2014
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Data;
using System.Runtime.InteropServices;
using System.Security;
namespace System.Data.SqlClient {
/// <summary>
/// Describes an error from a SQL database.
/// </summary>
[Serializable]
public sealed class SqlCredential
{
#region Fields
string uid = "";
SecureString pwd = null;
#endregion // Fields
#region Constructors
public SqlCredential (string user, SecureString password)
{
if (user == null)
throw new ArgumentNullException("UserID");
if (password == null)
throw new ArgumentNullException("Password");
this.uid = user;
this.pwd = password;
}
#endregion // Constructors
#region Properties
public string UserId {
get { return uid; }
}
public SecureString Password {
get { return pwd; }
}
#endregion
}
}