2012-06-20 3 views
3

WCF에 UserNamePasswordValidator을 사용하고 있습니다. 내 코드는 비슷합니다. 데이터베이스를 사용합니다. 이 방법으로 현재 연결 컨텍스트에 대한 정보를 얻는 방법을 알 수 있습니까? 나는 실패 통화연결 컨텍스트 및 UserNamePasswordValidator

public class MyCustomUserNameValidator : UserNamePasswordValidator 
{ 
    // This method validates users. It allows two users, test1 and test2 
    // with passwords 1tset and 2tset respectively. 
    // This code is for illustration purposes only and 
    // MUST NOT be used in a production environment because it is NOT secure. 
    public override void Validate(string userName, string password) 
    { 
     if (null == userName || null == password) 
     { 
      throw new ArgumentNullException(); 
     } 

     if (!(userName == "test1" && password == "1tset") && !(userName == "test2" && password == "2tset")) 
     { 
      throw new SecurityTokenException("Unknown Username or Password"); 
     } 
    } 
} 

답변