WCFテストクライアントから実行していたWCFサービスがあります。今では、ユーザ名とパスワードのカスタム認証をサービスに追加し、ユーザ名とパスワードをどのように渡すのかを知りたがっています。それでもWCF Test Client経由でクライアントの資格情報を指定することは可能ですか?ここでWCFテストクライアントからWCFサービスを実行しているときにクライアントの資格情報を指定する
私のカスタムバリデータとユーザーアカウントクラスです:
public class CustomUserValidator : UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
if (null == userName || null == password)
{
throw new ArgumentNullException();
}
UserAccountModel uam = new UserAccountModel();
if(uam.Login(userName, password))
return;
throw new SecurityTokenException("User invalid.");
}
}
public class UserAccountModel
{
private List<UserAccount> listUserAccounts = new List<UserAccount>();
public UserAccountModel()
{
using (UserAccountContext ctx = new UserAccountContext())
{
listUserAccounts = ctx.UserAccounts.ToList();
}
}
public bool Login(string _usrname, string _pwd)
{
return listUserAccounts.Count(lua => lua.Username.Equals(_usrname) && lua.Pwd.Equals(_pwd)) > 0;
}
}
コードをお知らせください。 –