Adding additional linked membership provider in asp.net -


i work on asp.net (hybrid webforms + mvc4) application provides videos of expert speakers employees @ various organizations. use asp.net membership authenticate users based on company work (each company has login), set roles determine videos have access to, , build reports etc.

however, company wants begin adding login individual users well. rewriting our entire membership system mean rebuilding large portion of site -- instead thinking of adding membership provider individuals map membership provider have organizations. envisioning following

1)the user logs on username , password using individual membership framework

2)the application maps user corresponding member in original (company) membership framework, , automatically authenticates user membership (invisible user) assigns correct roles etc based on organizatiom user belongs to. second membership layer on top of original.

i considering building extended tables individual users in sql server map current company members have -- however, prefer user membership provider individual users maps original membership provider, save writing crud code, forgot password , api comes membership framework. i'm wondering whether possible, or best practice in case.

my understanding of requirements need combine of membership providers 1 individual (to use 1 log-in users) , take advantage of existing implementation of current membership-providers.

based on requirements think use customized log-in view , map right membership provider @ time of user authentication process.

to clarify assumption, lets have these 2 existing providers on project solution:

<membership>   <providers>     <clear/>     <add name="organization1" type="mvcapplication.organization1" />     <add name="organization2" type="mvcapplication.organization2" />     .... 

and switch , save right provider if user valid.

public actionresult logon(logonmodel model, string returnurl) {   if (modelstate.isvalid)   {       var membershipprovider1 = membership.providers["organization1"];       if (membershipprovider1.validateuser(model.username, model.password))       {          // save provider on server memory while user's logged-in          return redirect(returnurl);       }        var membershipprovider2 = membership.providers["organization2"];       if (membershipprovider2.validateuser(model.username, model.password))       {          // save provider on server memory while user's logged-in          return redirect(returnurl);       }        modelstate.addmodelerror("", "the user name or password provided incorrect.");       return view(model);   } } 

this might not want bit of modification may solution aiming for.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -