Everyone,

I am trying to turn a single user web app into a multi-tennant system. Currently I have all data access calls going to a DAL with a set datbase, username and password.

My problem is this...I need to create a separate db for each tennant and theoretically each db would need its own username and pass to keep from having one username for all tennants with privildges to all db's.

Initially I was thinking that when the user authenticates to the userstore (one userstore for all tennants) that I could slip a db name and username back to the client in the auth ticket. But this got me to thinking about the effects on the DAL for other users.

Since there is only one DAL and it is only called once the app needs or edits data I believe that the DAL would then be considered "server side". In other words if I pass a db and username to it for one user...all users logged on will end up using this combination until it is changed again. I.e. :

User 1 logs in and sends a db and username to the DAL of database1 and user 1. Lets say a second user loggs on for another tennant. Now they send a db and username to the DAL of database2 and user2. Now if user 1 makes any changes the DAL is still set to the db and username of the last logged on client of database2 user2. User1 is no effectivly editing and reading from the wrong Database.

How can I work around this? I know that I could pass a username and db to the DAL on every data call but this seems horriably inefficient. Is there a way to set a "secession DAL" for each logged on user? Meaning I set the db and username one time when they log on, which is kept until they log off???

Thanks for your thoughts