Integration of dotnetnuke and membership (5-year Edition)
Step 1: Install dnn based on the existing membership
Http://www.cnblogs.com/shiningrise/archive/2007/08/13/854297.html
Step 2: Modify the logon method of provider. Membership. aspnetprovider and add the membership user to the dnn database (that is, the user that does not exist)
Http://www.cnblogs.com/shiningrise/archive/2007/08/22/864685.html
Step 3: Modify httpmodule. dnnmembership to add a membership user to the dnn database when the user not logged on from dnn is switched to the dnn System)
Next, let's write the third step.
Copy httpmodule. dnnmembership to the new dnnmembership as httpmodule. dnnmembershipfiveyears
Create a method
Private function creatednnuser (byref user as userinfo) as usercreatestatus
Dim objsecurity as new portalsecurity
Dim username as string = objsecurity. inputfilter (user. username, portalsecurity. filterflag. noscripting or portalsecurity. filterflag. noanglebrackets or portalsecurity. filterflag. nomarkup)
Dim email as string = objsecurity. inputfilter (user. Email, portalsecurity. filterflag. noscripting or portalsecurity. filterflag. noanglebrackets or portalsecurity. filterflag. nomarkup)
Dim lastname as string = objsecurity. inputfilter (user. lastname, portalsecurity. filterflag. noscripting or portalsecurity. filterflag. noanglebrackets or portalsecurity. filterflag. nomarkup)
Dim firstname as string = objsecurity. inputfilter (user. firstname, portalsecurity. filterflag. noscripting or portalsecurity. filterflag. noanglebrackets or portalsecurity. filterflag. nomarkup)
Dim createstatus as usercreatestatus = usercreatestatus. Success
Dim displayname as string = objsecurity. inputfilter (user. displayname, portalsecurity. filterflag. noscripting or portalsecurity. filterflag. noanglebrackets or portalsecurity. filterflag. nomarkup)
Dim updatepassword as Boolean = user. Membership. updatepassword
Dim isapproved as Boolean = user. Membership. Approved
Try
'The following sentence is a bit inside. Let's look at it.
Dim dataprovider as dotnetnuke. Security. Membership. Data. dataprovider = dotnetnuke. Security. Membership. Data. dataprovider. instance ()
User. userid = ctype (dataprovider. adduser (user. portalid, username, firstname, lastname, user. affiliateid, user. issuperuser, email, displayname, updatepassword, isapproved), integer)
Catch ex as exception
'Clear user (Duplicate User Information)
User = nothing
Createstatus = usercreatestatus. providererror
End try
Return createstatus
End Function
Modify the public sub onauthenticaterequest (byval s as object, byval e as eventargs) Method
If request. isauthenticated = true and not _ portalsettings is nothing then
Dim arrportalroles () as string
Dim objrolecontroller as new rolecontroller
Dim objuser as userinfo = usercontroller. getcacheduser (_ portalsettings. portalid, context. User. Identity. Name)
***************************** *************/
Dim user as userinfo = nothing
User = objuser
If (user is nothing) then
Dim username as string = context. User. Identity. Name
User = new userinfo
User. portalid = _ portalsettings. portalid
User. Username = Username
User. Email = username + "@ 163.com"
User. firstname = Username
User. lastname = Username
User. displayname = Username
Me. creatednnuser (User)
Objuser = usercontroller. getcacheduser (_ portalsettings. portalid, context. User. Identity. Name)
End if
/*************************************** *********/
Modify web. config
<! -- <Add name = "dnnmembership" type = "dotnetnuke. httpmodules. dnnmembershipmodule, dotnetnuke. httpmodules. dnnmembership"/> -->
<Add name = "dnnmembershipfiveyears" type = "dotnetnuke. httpmodules. dnnmembershipmodulefiveyears, dotnetnuke. httpmodules. dnnmembershipfiveyears"/>
Dnn4.5.5
Click to download source code