SqlCredential 클래스

정의

SqlCredential은 SQL Server 인증을 사용하여 로그인 시도에 대해 암호를 더욱 안전하게 지정하는 방법을 제공합니다.

SqlCredential은 SQL Server 인증에 사용되는 사용자 ID와 암호로 이루어집니다. SqlCredential 개체의 암호가 SecureString 형식입니다.

SqlCredential은 상속될 수 없습니다.

Windows 인증(Integrated Security = true)은 SQL Server 데이터베이스에 로그인하는 가장 안전한 방법입니다.

public ref class SqlCredential sealed
public sealed class SqlCredential
type SqlCredential = class
Public NotInheritable Class SqlCredential
상속
SqlCredential

설명

를 사용하여 Credential 연결의 SqlCredential 개체를 얻거나 설정합니다. 를 사용하여 ChangePassword 개체를 통해 SqlCredential 사용자의 암호를 변경합니다. 개체가 SqlCredential 연결 풀 동작에 미치는 영향에 대한 자세한 내용은 SQL Server 연결 풀링(ADO.NET)을 참조하세요.

InvalidOperationException null SqlCredential 이 아닌 개체가 다음 연결 문자열 키워드와의 연결에서 사용되는 경우 예외가 발생합니다.

  • Integrated Security = true

  • Password

  • User ID

  • Context Connection = true

다음 샘플에서는 를 사용하여 SQL Server 데이터베이스에 Credential연결합니다.

// change connection string in the APP.CONFIG file  
<connectionStrings>  
  <add name="MyConnString"  
       connectionString="Initial Catalog=myDB;Server=myServer"  
       providerName="System.Data.SqlClient" />  
</connectionStrings>  

// then use the following snippet:  
using System.Configuration;  

System.Windows.Controls.TextBox txtUserId = new System.Windows.Controls.TextBox();  
System.Windows.Controls.PasswordBox txtPwd = new System.Windows.Controls.PasswordBox();  

Configuration config = Configuration.WebConfigurationManager.OpenWebConfiguration(Null);  
ConnectionStringSettings connString = config.ConnectionStrings.ConnectionString["MyConnString"];  

using (SqlConnection conn = new SqlConnection(connString.ConnectionString))  
{  
SecureString pwd = txtPwd.SecurePassword;  
pwd.MakeReadOnly();  
SqlCredential cred = new SqlCredential(txtUserId.Text, pwd);  
conn.Credential = cred;  
conn.Open();  

생성자

SqlCredential(String, SecureString)

SqlCredential 형식의 개체를 만듭니다.

속성

Password

SqlCredential 개체의 암호 구성 요소를 가져옵니다.

UserId

SqlCredential 개체의 사용자 ID 구성 요소를 가져옵니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보