Hi
I am wondering how do I extend the membership stuff in asp.net?
When a user logs in I want to check the UserName and Password. Of course the standard asp.net membership does this(this it is ValidateUser()).
I also want to check another field called "institution". If a user types something in this box I want to verify if the "institution", "userName" and "password" match what is in the database.
If a user leaves the "institution" blank then I just want to use it default ValidateUser() method that is provided in asp.net and check only "userName" and "password".
So can I overload the ValdiateUser() method? Or will I have to write my own one to handle this new case?
Where would I store this "institution" field in the database? I heard something about people recommending the "Profile" table but I am not sure.
Also how can I change the membership to treat these as 3 different users
Institution: ABC UserName: A09410515 Password: 1234567
Institution: GHA UserName: A09410515 Password: 1234567
UserName: A09410515 Password: 1234567
So as my database should be concerned these should be 3 unique users. Of course in the case that my database already would have the same information stored in it.
For example.
Institution: ABC UserName: A09410515 Password: 1234567
and someone tries to sign up with the exact same information for "UserName" and "Institution" then it would spit back an error about being duplicate names.
-
Yes, you can create a custom membership provider. Your provider will implement MembershipProvider giving you full control over creating an interface between the membership system and extended database schema. Writing A Custom Membership Provider for your ASP.NET 2.0 Web Site is a detailed example.
chobo2 : Hi Thanks for the links. I am still a bit confused though. Where do I store these extra fields that I would be adding. Like do I add it to the profile or what? Like I am making a custom provider so that I can merge my asp.net db and my db together but I am using mssql server. Also I noticed they override that methods. I still want to use the default verify method. So do I make 2 overload methods. One with my custom verify and one method calling the default verify method?From JP Alioto -
The lazy way of doing this would be to combine institution and username together to create the actual username.
Thus you'd have 3 distinct usernames: ABC&A09410515, GHA&A09410515, and &A09410515. Just don't allow a user to use & in a username.
Then, before creating the user or logging in you just combine the two strings together.
I can't think of any significant problems that can't be fixed with a simple hack (e.g. displaying the username (use username.split('&')[1] ), but JP's post is definitely the "right" way to do it.
James
From James S -
You might use Application Name as the institution, that way you would have the same user name in different applications
Rodrigo.
From Rodrigo
0 comments:
Post a Comment