1 //------------------------------------------------------------------------------
2 // <copyright file="SqlCredential.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 // <owner current="true" primary="false">Microsoft</owner>
7 //------------------------------------------------------------------------------
9 namespace System.Data.SqlClient
12 using System.Security;
13 using System.Data.Common;
15 // Represent a pair of user id and password which to be used for SQL Authentication
16 // SqlCredential takes password as SecureString which is better way to store security sensitive information
17 // This class is immutable
18 public sealed class SqlCredential
21 SecureString _password;
31 public SqlCredential(string userId, SecureString password)
35 throw ADP.ArgumentNull("userId");
38 if (userId.Length > TdsEnums.MAXLEN_USERNAME)
40 throw ADP.InvalidArgumentLength("userId", TdsEnums.MAXLEN_USERNAME);
45 throw ADP.ArgumentNull("password");
48 if (password.Length > TdsEnums.MAXLEN_PASSWORD)
50 throw ADP.InvalidArgumentLength("password", TdsEnums.MAXLEN_PASSWORD);
53 if (!password.IsReadOnly())
55 throw ADP.MustBeReadOnly("password");
73 public SecureString Password
81 } // System.Data.SqlClient namespace