3

I´am using UserNamePasswordValidator for WCF. My code is similar. I use database. Does any know how can I get information about current connection context in this method. I want to log ip address of unsuccessful calls

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");
        }
    }
}
Damith
  • 62,401
  • 13
  • 102
  • 153
Tomas Horvath
  • 97
  • 1
  • 1
  • 3

1 Answers1

0

Check this

Getting the IP address of server in ASP.NET?

in your exception you can get ip address.

Community
  • 1
  • 1
manny
  • 1,878
  • 2
  • 15
  • 31