Anubis2005
asked on
Membership provider changes after successful login (multiple membership providers)
Hello All,
I have a site in which I'm intending to use multiple membership providers. I'm using my own custom membership provider to provide access to several data stores depending on the section in which the user's information resides.
The actual login functions correctly using the built-in ASP.NET Login component in which I've manually specified the membership provider it should validate against. When I run a trace on it's actions, I can see that it attempts the 'validateuser' against the correct data store and continues to redirect the user to their applicable section.
The problem is that once they are logged in and the site (or I) call 'GetUser' to get the users information or permissions, the membership provider reverts to the site's default provider.
In my custom membership provider I'm only overriding the methods for GetUser and Validate user which is working perfectly fine for a singular membership provider, but not when using a different provider.
How can I ensure that the correct membership provider is retained with the user's membership details? Is there a method that I need to override/append in order to achieve what I'm looking for?
Thanks
Anubis.
I have a site in which I'm intending to use multiple membership providers. I'm using my own custom membership provider to provide access to several data stores depending on the section in which the user's information resides.
The actual login functions correctly using the built-in ASP.NET Login component in which I've manually specified the membership provider it should validate against. When I run a trace on it's actions, I can see that it attempts the 'validateuser' against the correct data store and continues to redirect the user to their applicable section.
The problem is that once they are logged in and the site (or I) call 'GetUser' to get the users information or permissions, the membership provider reverts to the site's default provider.
In my custom membership provider I'm only overriding the methods for GetUser and Validate user which is working perfectly fine for a singular membership provider, but not when using a different provider.
How can I ensure that the correct membership provider is retained with the user's membership details? Is there a method that I need to override/append in order to achieve what I'm looking for?
Thanks
Anubis.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Hi guru_sami,
Thanks for the reply.
This is ok for when I manually want to call it, but asp.net when redirecting to protected pages it's calling the default provider instead of the correct provider and throws the user out.
I can't seem to find a way to tell asp.net that it should maintain the specified provider.
Thanks
Anubis.
Thanks for the reply.
This is ok for when I manually want to call it, but asp.net when redirecting to protected pages it's calling the default provider instead of the correct provider and throws the user out.
I can't seem to find a way to tell asp.net that it should maintain the specified provider.
Thanks
Anubis.
-->asp.net when redirecting to protected pages it's calling the default provider
I didn't get that part...because once you set forms authentication cookie, it shouldn't matter unless you are talking of roles and roles provider.
I didn't get that part...because once you set forms authentication cookie, it shouldn't matter unless you are talking of roles and roles provider.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Solved the issue myself by writing a custom class to handle what I wanted. Not a perfect solution, but it's working.
ASKER
Thanks for the reply. Although this might work, in a case where usernames are the same across multiple providers, it wouldn't work properly.
I've been looking at the methods/steps behind the scenes of how the login component authenticates a user, I'm successfully overriding the 'ValidateUser' part of this, but obviously .NET creates a MembershipUser object for the logged in user at some point.
If I can find at what exact point this is done, I could override it to ensure that my membership user maintains the appropriate provider.
I've been searching for 'behind the scenes' details of the login control's actions but I'm coming up empty.
Thanks
Anubis.