1

I'm using a custom MembershipProvider in my application, and it's all wired up correctly. The only missing piece is the ability to display custom error messages depending on the result of the authentication.

The ValidateUser() method only returns true or false, but I would like to also return a more detailed message in case the validation fails. At the moment I'm using a Session variable to store it, and then read that variable in the login page.

Is there a better way of doing it?

Farinha
  • 17,636
  • 21
  • 64
  • 80
  • What kind of stuff do you want to check on exactly ? .. like if it's false is the credentials are wrong or he's just not approved .. this is the example in my head for now. Could you list the things you want to customize the error according to them ? – Mazen Elkashef Apr 18 '11 at 16:50

2 Answers2

0

More detailed message from ValidateUser can produce security vulnerability.

You can validate input strings before call ValidateUser.

gandjustas
  • 1,925
  • 14
  • 12
0

As @gandjustas says, there's not much you can do from within the custom membership provider, as ValidateUser only gives true or false when authenticating, to reduce unintentional leakage of information that could help an attacker.

As you say, though, you may want to pass back more information to the user, such as "Your account has not yet been approved", and this is the situation that I am in. The following Stack Overflow posting may be of some assistance, particularly the first link given in the accepted answer.

Community
  • 1
  • 1
David Keaveny
  • 3,904
  • 2
  • 38
  • 52