views:

282

answers:

1

Hello,

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?

+3  A: 

Hey,

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.

Brian
Thx.I understand that custom methods isn't the right way.The tenants are created on the fly, how can I specify this in the configuration file?Or can I store it somewhere else?
Masna
If you are developing a custom provider, you could easily store this somewhere else yes. It could be in app settings, or a custom config section, or a static object, or an external resource like the DB/xml file... to name a few :-) It depends on how on the fly you need it though... Without more details I can't help with any more details.
Brian