0

I implemented a custom membership provider in ASP.net MVC, and can't figure out how to make the username non case-sensitive at signin. So, for example, "Solomon" could log in, but "solomon" could not.

My implementation is very bare bones. I basically just wrote code for ValidateUser(), and Change Password().

Thanks for the help!

Sky Sanders
  • 36,396
  • 8
  • 69
  • 90
Solomon
  • 6,145
  • 3
  • 25
  • 34

2 Answers2

2

shimms is halfway there.

Splitting a logical operation between two 'tiers' is not a sound practice.

A logical operation should be atomic. So just lower both in the query...

e.g.

where Lower(username)=Lower(@username)
Sky Sanders
  • 36,396
  • 8
  • 69
  • 90
0

Convert the username to its lowercase version, and then compare it to the lowercase version of the username in the database. The ANSI SQL would be:

WHERE LOWER(username) = :username

Supply the username parameter as:

... = username.ToLower();
Michael Shimmins
  • 19,961
  • 7
  • 57
  • 90
  • You have a brittle logical dependency here, shimms. You should not split a logical operation. This should be an atomic comparison in the database/query. – Sky Sanders Mar 06 '10 at 05:18