Role Management bind users to diffrerent applicationshttp://forums.asp.net/t/1796111.aspx/1?Role+Management+bind+users+to+diffrerent+applicationsMon, 14 May 2012 10:52:39 -040017961114947360http://forums.asp.net/p/1796111/4947360.aspx/1?Role+Management+bind+users+to+diffrerent+applicationsRole Management bind users to diffrerent applications <p>Folks,</p> <p>How can i bind users to different applicationsID's (in aspnetdb database).</p> <p>I have 10 companies in one aspnetdb database. Want to bind users to their own companies..</p> <p>Any ideas?</p> 2012-04-23T22:56:14-04:004949751http://forums.asp.net/p/1796111/4949751.aspx/1?Re+Role+Management+bind+users+to+diffrerent+applicationsRe: Role Management bind users to diffrerent applications <p>Hi jagjot,</p> <p>When you configure an ASP.NET Membership provider in web.config file, you can specify the &quot;applicationName&quot; 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).</p> <pre class="prettyprint">&lt;membership defaultProvider=&quot;SqlProvider&quot; &gt; &lt;providers&gt; &lt;clear /&gt; &lt;add name=&quot;SqlProvider&quot; type=&quot;System.Web.Security.SqlMembershipProvider&quot; connectionStringName=&quot;MySqlConnection&quot; ...... applicationName=&quot;MyApplication&quot; ....... /&gt; &lt;/providers&gt; &lt;/membership&gt;</pre> <p><br />&nbsp;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)</p> <p>And in your code, you can use Membership.Providers property to reference all the providers you have configured in web.config. e.g.</p> <pre class="prettyprint">var provider1 = Membership.Providers["NameOfProvider1"]; // use provider1 to manipulate users </pre> <p><br> #Membership.Providers Property <br> <a href="http://msdn.microsoft.com/en-us/library/system.web.security.membership.providers.aspx">http://msdn.microsoft.com/en-us/library/system.web.security.membership.providers.aspx</a></p> <p>here are some other web articles mentioned use multiple membership providers for in an ASP.NET web application.</p> <p>#Using two Membership Providers for ASP.NET logins <br> <a href="http://www.stevideter.com/2008/03/20/using-two-membership-providers-for-aspnet-logins/">http://www.stevideter.com/2008/03/20/using-two-membership-providers-for-aspnet-logins/</a></p> <p>#Working with multiple membership and role providers <br> <a href="http://www.sitefinity.com/devnet/kb/sitefinity-3-x/working-with-multiple-membership-and-role-providers.aspx">http://www.sitefinity.com/devnet/kb/sitefinity-3-x/working-with-multiple-membership-and-role-providers.aspx</a></p> <p>&nbsp;</p> 2012-04-25T04:30:54-04:004950046http://forums.asp.net/p/1796111/4950046.aspx/1?Re+Role+Management+bind+users+to+diffrerent+applicationsRe: Role Management bind users to diffrerent applications <p>Steven,</p> <p>Thanks for your quick response. I am going to do bit of experimentation on your above solution and get back to you ASAP.</p> <p>Cheers</p> 2012-04-25T07:13:46-04:004950860http://forums.asp.net/p/1796111/4950860.aspx/1?Re+Role+Management+bind+users+to+diffrerent+applicationsRe: Role Management bind users to diffrerent applications <p>hi jagjot</p> <p>check this post</p> <p><a href="http://www.aspdotnet-suresh.com/2012/01/assign-or-remove-roles-to-users-in.html">http://www.aspdotnet-suresh.com/2012/01/assign-or-remove-roles-to-users-in.html</a></p> 2012-04-25T12:46:17-04:004979610http://forums.asp.net/p/1796111/4979610.aspx/1?Re+Role+Management+bind+users+to+diffrerent+applicationsRe: Role Management bind users to diffrerent applications <p>Thanks Steven..</p> <p>After my reaserch i also came to same conclusion - this is the best and robust technique available.</p> <p>Surely this coud be better. I will write a class and db SP to sort this out and share with you..</p> <p>Thank again...</p> 2012-05-14T10:52:39-04:00