Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi tenant membership provider ASP.NET MVC

I'm building a multi-tenant app with ASP.NET MVC and have a problem with validating users.

Situation

I have:

-a table with User(ID, Name, FirstName, Email) This table is made, so that a users who is registered in two tenants doesn't need to login again.

-a table with Tentantuser(ID, TenantID, UserID (FK to table User), UserName, Loginname, Password, Active) This table contains de login en password for one tenant.

Example:

  • UserX is registered in TenantA and TenantB
  • UserX logs in on TenantA, with his login and password for TenantA
  • System verifies or login and password are correct in the table TenantUser
  • System validates UserX which userID corresponds to the Id in the table User
  • UserX goes to TenantB and is automatically logged in

My problem:

How can I create a custom Provider so I can check the login & password in a tenant? For example:

public abstract bool ValidateUser(string username,string password);

How can I say to my provider on which tenant the user is?

How can I change this in something like:

 public overrides bool ValidateUser(string username,string password, string tenant); ?

Or what is another way to solve this issue?

like image 440
Masna Avatar asked May 20 '10 14:05

Masna


1 Answers

The application name parameter can be used to identify tenant a/b, which can be specified in the configuration file. Then, in your custom provider, you can use this to pull the right entry for the tenant. Don't get into setting up custom methods; that would be a pain.

HTH.

like image 87
Brian Mains Avatar answered Oct 11 '22 14:10

Brian Mains