Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 14, 2012 10:52 AM by jagjot
Apr 23, 2012 10:56 PM|LINK
How can i bind users to different applicationsID's (in aspnetdb database).
I have 10 companies in one aspnetdb database. Want to bind users to their own companies..
Apr 25, 2012 04:30 AM|LINK
When you configure an ASP.NET Membership provider in web.config file, you can specify the "applicationName" attribute. Then, when you creating new users via this membership provider, the created user will be associated with the certain applicationName(you
set for this provider).
<membership defaultProvider="SqlProvider" >
Thus, if you want to be able to create and manipulate users bound to multiple applicationNames(no matter they're stored in the same database or not), you need to configure multiple membershp providers in web.config. BTW, so far it seems there is no built-in API for you to change the "applicationName" of user after you have created it(you might need to manually change the table columns in database tables)
And in your code, you can use Membership.Providers property to reference all the providers you have configured in web.config. e.g.
var provider1 = Membership.Providers["NameOfProvider1"];
// use provider1 to manipulate users
here are some other web articles mentioned use multiple membership providers for in an ASP.NET web application.
#Using two Membership Providers for ASP.NET logins
#Working with multiple membership and role providers
Apr 25, 2012 07:13 AM|LINK
Thanks for your quick response. I am going to do bit of experimentation on your above solution and get back to you ASAP.
Apr 25, 2012 12:46 PM|LINK
check this post
May 14, 2012 10:52 AM|LINK
After my reaserch i also came to same conclusion - this is the best and robust technique available.
Surely this coud be better. I will write a class and db SP to sort this out and share with you..