Using DNN authentication and authorization info from another ASP.NET app

后端 未结 2 1539
孤城傲影
孤城傲影 2021-01-28 08:37

I have an ASP.NET web application \"K\" that has its own authentication and authorization built on SimpleMembershipProvider.

Now I want to set up a web site that has ap

2条回答
  •  情歌与酒
    2021-01-28 09:06

    Here is how I solved it.

    • Put DNN and "K" as direct child siblings of web root.
    • Make DNN and "K" have the same MachineKey.
    • Write User Migration sql script, from DNN to "K".
    • Make a link from DNN to "K".
    • Modify "K" web.config authentication section like below. Key point is loginUrl and name.

    >

    
      
    
    
    • Disable any code in "K" that allows the user to log in directly to "K".
    • When the user visits "K" for the first time, execute user migration sql script. (you could initiate migration script in any moment that fits you the most.)

    Now, the user will log in onto DNN, and click a link to access "K". When this happens, "K" can behave as if the user actually logged in using "K" application, like reading roles from Web.Security, etc. That comes for free since you made its forms authentication cookie name and MachineKey synced between two applications.

提交回复
热议问题