1

Our site has got two ASP.NET membership providers. The built in one, and a custom one (SqlMembershipProvider.

I am able to log into both no problems, but I don't necessary require the ability to have both logged in at the same time.

The issue I have is as follows:

User "person_a@site.com" logs into the built in provider. They then navigate to the section of the site where we require the custom provider.

On this page, I can check if they are authenticated, and get their username. I can then get a MembershipUser object form the custom providers GetUser method. (HttpContext.Current.User.Identity.Name)

It is possible (and very likely) that the username "person_a@site.com" could also exist in the users for the custom provider.

But, I don't want them to be logged in here, as they haven't authenticated against the custom provider.

So, is it possible to check which proivider HttpContext.Current.User was generated from.

Hope this all makes sense!!

Danny
  • 11
  • 1
  • Hi Danny, what does the custom provider deliver that the MS one doesn't and have you considered using Roles to control access to different sections of the site? – Lazarus Aug 11 '10 at 11:47
  • This is a solution using Umbraco, so the built in one is used for there. The custom one is required to validate against a database table. There are two distinct areas for users to loggon to, and these loggins are not shared. One idea I had was setting a Session varible when users loggon to each area, i.e. Session[“isMember”] when they log on to the members area, and Session[“isDef”] when they log in else where. I can then check this session varible when I an autenticating the users. – Danny Aug 11 '10 at 12:05

1 Answers1

0

Yes, if you notice on the RolePrincipal there is a property called ProviderName.

Typically when people roll their own providers they omit usage of this field.

In your case, simply modify your custom provider to identify itself, if it does not already, and check that property of the user.

Sky Sanders
  • 36,396
  • 8
  • 69
  • 90