Combine dotnetnuke and membership (five-year version). Step 3: Modify httpmodule. dnnmembership

Source: Internet
Author: User
Tags dnn dotnetnuke

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.