Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Configure DNN environment question?Configure DNN environment question?
Previous
 
Next
New Post
10/19/2009 6:29 AM
 

I have recycled code from /admin/authentication/Login.ascx but cannot get ctlPassword object to behave correct ... I do have a reference to the object but som of its parameters are missing and how do I adjust this wrongly configuration of mine? Or how do I approach the problem so I find what is wrong?

 

 

 

the code for this file:

 

Imports System.Web.UI
Imports System.Globalization
Imports System.Collections.Generic
Imports System.Reflection
Imports DotNetNuke
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports System.IO
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Entities.Profile
Imports DotNetNuke.Security.Membership
Imports DotNetNuke.Services.Authentication
Imports DotNetNuke.Services.Mail
Imports DotNetNuke.UI.UserControls
Imports DotNetNuke.UI.Skins.Controls.ModuleMessage
Imports DotNetNuke.Entities.Users


Namespace DotNetNuke.BetFriends.Modules.BFSMiniLogin

    Partial Public Class MiniLogin2
        Inherits UserModuleBase

#Region "Private Members"

        Private loginControls As New List(Of AuthenticationLoginBase)

#End Region

#Region "Protected Properties"

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Gets and sets the current AuthenticationType
        ''' </summary>
        ''' <history>
        '''     [cnurse]    07/12/2007  Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Protected Property AuthenticationType() As String
            Get
                Dim _AuthenticationType As String = Null.NullString
                If Not view_state("AuthenticationType") Is Nothing Then
                    _AuthenticationType = CStr(view_state("AuthenticationType"))
                End If
                Return _AuthenticationType
            End Get
            Set(ByVal Value As String)
                view_state("AuthenticationType") = Value
            End Set
        End Property

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Gets and sets a flag that determines whether the user should be automatically registered
        ''' </summary>
        ''' <history>
        '''     [cnurse]    07/16/2007  Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Protected Property AutoRegister() As Boolean
            Get
                Dim _AutoRegister As Boolean = Null.NullBoolean
                If Not view_state("AutoRegister") Is Nothing Then
                    _AutoRegister = CBool(view_state("AutoRegister"))
                End If
                Return _AutoRegister
            End Get
            Set(ByVal Value As Boolean)
                view_state("AutoRegister") = Value
            End Set
        End Property

        Protected Property ProfileProperties() As NameValueCollection
            Get
                Dim _Profile As New NameValueCollection
                If Not view_state("ProfileProperties") Is Nothing Then
                    _Profile = CType(view_state("ProfileProperties"), NameValueCollection)
                End If
                Return _Profile
            End Get
            Set(ByVal value As NameValueCollection)
                view_state("ProfileProperties") = value
            End Set
        End Property

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Gets and sets the current Page No
        ''' </summary>
        ''' <history>
        '''     [cnurse]    03/09/2006  Created
        '''     [cnurse]    07/03/2007  Moved from Sign.ascx.vb
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Protected Property PageNo() As Integer
            Get
                Dim _PageNo As Integer = 0
                If Not view_state("PageNo") Is Nothing Then
                    _PageNo = CInt(view_state("PageNo"))
                End If
                Return _PageNo
            End Get
            Set(ByVal Value As Integer)
                view_state("PageNo") = Value
            End Set
        End Property

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Gets the Redirect URL (after successful login)
        ''' </summary>
        ''' <history>
        '''     [cnurse]    04/18/2006  Created
        '''     [cnurse]    07/03/2007  Moved from Sign.ascx.vb
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Protected ReadOnly Property RedirectURL() As String
            Get
                Dim _RedirectURL As String = ""

                Dim setting As Object = UserModuleBase.GetSetting(PortalId, "Redirect_AfterLogin")

                If CType(setting, Integer) = Null.NullInteger Then
                    If Not Request.QueryString("returnurl") Is Nothing Then
                        ' return to the url passed to signin
                        _RedirectURL = HttpUtility.UrlDecode(Request.QueryString("returnurl"))
                        ' redirect url should never contain a protocol ( if it does, it is likely a cross-site request forgery attempt )
                        If _RedirectURL.Contains("://") Then
                            _RedirectURL = ""
                        End If
                    End If
                    If Not Request.Params("appctx") Is Nothing Then
                        'HACK return to the url passed to signin (LiveID)
                        _RedirectURL = HttpUtility.UrlDecode(Request.Params("appctx"))
                        ' redirect url should never contain a protocol ( if it does, it is likely a cross-site request forgery attempt )
                        If _RedirectURL.Contains("://") Then
                            _RedirectURL = ""
                        End If
                    End If
                    If _RedirectURL = "" Then
                        If PortalSettings.LoginTabId <> -1 And PortalSettings.HomeTabId <> -1 Then
                            ' redirect to portal home page specified
                            _RedirectURL = NavigateURL(PortalSettings.HomeTabId)
                        Else
                            ' redirect to current page
                            _RedirectURL = NavigateURL()
                        End If
                    End If
                Else ' redirect to after login page
                    _RedirectURL = NavigateURL(CType(setting, Integer))
                End If

                'replace language parameter in querystring, to make sure that user will see page in correct language
                If UserId <> -1 Then
                    If User.Profile.PreferredLocale <> CultureInfo.CurrentCulture.Name Then
                        _RedirectURL = UrlUtils.replaceQSParam(_RedirectURL, "language", User.Profile.PreferredLocale)
                    End If
                End If

                'check for insecure account defaults
                Dim qsDelimiter As String = "?"
                If _RedirectURL.Contains("?") Then
                    qsDelimiter = "&"
                End If
                If LoginStatus = UserLoginStatus.LOGIN_INSECUREADMINPASSWORD Then
                    _RedirectURL = _RedirectURL & qsDelimiter & "runningDefault=1"
                ElseIf LoginStatus = UserLoginStatus.LOGIN_INSECUREHOSTPASSWORD Then
                    _RedirectURL = _RedirectURL & qsDelimiter & "runningDefault=2"
                End If

                Return _RedirectURL

            End Get
        End Property

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Gets whether the Captcha control is used to validate the login
        ''' </summary>
        ''' <history>
        '''     [cnurse]    07/12/2007  Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Protected ReadOnly Property UseCaptcha() As Boolean
            Get
                Dim setting As Object = GetSetting(PortalId, "Security_CaptchaLogin")
                Return CType(setting, Boolean)
            End Get
        End Property

        Protected Property LoginStatus() As UserLoginStatus
            Get
                Dim _LoginStatus As UserLoginStatus = UserLoginStatus.LOGIN_FAILURE
                If Not view_state("LoginStatus") Is Nothing Then
                    _LoginStatus = CType(view_state("LoginStatus"), UserLoginStatus)
                End If
                Return _LoginStatus
            End Get
            Set(ByVal value As UserLoginStatus)
                view_state("LoginStatus") = value
            End Set
        End Property

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Gets and sets the current UserToken
        ''' </summary>
        ''' <history>
        '''     [cnurse]    07/12/2007  Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Protected Property UserToken() As String
            Get
                Dim _UserToken As String = 0
                If Not view_state("UserToken") Is Nothing Then
                    _UserToken = CStr(view_state("UserToken"))
                End If
                Return _UserToken
            End Get
            Set(ByVal Value As String)
                view_state("UserToken") = Value
            End Set
        End Property

#End Region

#Region "Private Methods"

        Private Sub DisplayLoginControl(ByVal authLoginControl As AuthenticationLoginBase, ByVal addHeader As Boolean, ByVal addFooter As Boolean)
            'Create a <div> to hold the control
            Dim container As HtmlGenericControl = New HtmlGenericControl()
            container.ID = authLoginControl.AuthenticationType

            'Add Settings Control to Container
            container.Controls.Add(authLoginControl)

            'Add a Section Header
            Dim sectionHeadControl As SectionHeadControl = Nothing
            If addHeader Then
                sectionHeadControl = CType(LoadControl("~/controls/SectionHeadControl.ascx"), SectionHeadControl)
                sectionHeadControl.IncludeRule = True
                sectionHeadControl.CssClass = "Head"
                sectionHeadControl.Text = Localization.GetString("Title", authLoginControl.LocalResourceFile)

                sectionHeadControl.Section = container.ID

                'Add Section Head Control to Container
                pnlLoginContainer.Controls.Add(sectionHeadControl)
            End If

            'Add Container to Controls
            pnlLoginContainer.Controls.Add(container)


            'Add LineBreak
            If addFooter Then
                pnlLoginContainer.Controls.Add(New LiteralControl("<br/>"))
            End If

            pnlLoginContainer.Visible = True
        End Sub

        Private Sub DisplayTabbedLoginControl(ByVal authLoginControl As AuthenticationLoginBase, ByVal Tabs As DotNetNuke.UI.WebControls.TabStripTabCollection)

            Dim tab As New DotNetNuke.UI.WebControls.DNNTab(Localization.GetString("Title", authLoginControl.LocalResourceFile))
            tab.ID = authLoginControl.AuthenticationType

            tab.Controls.Add(authLoginControl)
            Tabs.Add(tab)
            tsLogin.Visible = True

        End Sub

        Private Sub BindLogin()
            If PortalSettings.UserRegistration = PortalRegistrationType.NoRegistration Then
                tdRegister.Visible = False
            End If
            lblLogin.Text = Localization.GetSystemMessage(PortalSettings, "MESSAGE_LOGIN_INSTRUCTIONS")

            Dim authSystems As List(Of AuthenticationInfo) = AuthenticationController.GetEnabledAuthenticationServices()
            Dim defaultLoginControl As AuthenticationLoginBase = Nothing

            For Each authSystem As AuthenticationInfo In authSystems
                Dim authLoginControl As AuthenticationLoginBase = CType(LoadControl("~/" & authSystem.LoginControlSrc), AuthenticationLoginBase)

                ' set the control ID to the resource file name ( ie. controlname.ascx = controlname )
                ' this is necessary for the Localization in PageBase
                authLoginControl.AuthenticationType = authSystem.AuthenticationType
                authLoginControl.ID = Path.GetFileNameWithoutExtension(authSystem.LoginControlSrc) + "_" + authSystem.AuthenticationType
                authLoginControl.LocalResourceFile = authLoginControl.TemplateSourceDirectory & "/" & Services.Localization.Localization.LocalResourceDirectory & "/" & Path.GetFileNameWithoutExtension(authSystem.LoginControlSrc)
                authLoginControl.RedirectURL = RedirectURL
                authLoginControl.ModuleConfiguration = Me.ModuleConfiguration

                AddHandler authLoginControl.UserAuthenticated, AddressOf Me.UserAuthenticated

                If authSystem.AuthenticationType = "DNN" Then
                    defaultLoginControl = authLoginControl
                End If

                'Check if AuthSystem is Enabled
                If authLoginControl.Enabled Then
                    'Add Login Control to List
                    loginControls.Add(authLoginControl)
                End If
            Next

            Dim authCount As Integer = loginControls.Count
            Select Case authCount
                Case 0
                    'No enabled controls - inject default dnn control
                    DisplayLoginControl(defaultLoginControl, False, False)
                Case 1
                    'We don't want the control to render with tabbed interface
                    DisplayLoginControl(loginControls(0), False, False)
                Case Else
                    For Each authLoginControl As AuthenticationLoginBase In loginControls
                        DisplayTabbedLoginControl(authLoginControl, tsLogin.Tabs)
                    Next
            End Select
        End Sub

        Private Sub BindRegister()
            lblType.Text = AuthenticationType
            lblToken.Text = UserToken

            ' Verify that the current user has access to this page
            If PortalSettings.UserRegistration = PortalRegistrationType.NoRegistration And Request.IsAuthenticated = False Then
                Response.Redirect(NavigateURL("Access Denied"), True)
            End If

            lblRegisterHelp.Text = Localization.GetSystemMessage(PortalSettings, "MESSAGE_REGISTRATION_INSTRUCTIONS")
            Select Case PortalSettings.UserRegistration
                Case PortalRegistrationType.PrivateRegistration
                    lblRegisterHelp.Text += Localization.GetString("PrivateMembership", Localization.SharedResourceFile)
                Case PortalRegistrationType.PublicRegistration
                    lblRegisterHelp.Text += Localization.GetString("PublicMembership", Localization.SharedResourceFile)
                Case PortalRegistrationType.VerifiedRegistration
                    lblRegisterHelp.Text += Localization.GetString("VerifiedMembership", Localization.SharedResourceFile)
            End Select

            If AutoRegister Then
                InitialiseUser()
            End If

            Dim UserValid As String = True
            If String.IsNullOrEmpty(User.Username) OrElse String.IsNullOrEmpty(User.Email) OrElse String.IsNullOrEmpty(User.FirstName) OrElse String.IsNullOrEmpty(User.LastName) Then
                UserValid = Null.NullBoolean
            End If

            If AutoRegister AndAlso UserValid Then
                ctlUser.Visible = False
                lblRegisterTitle.Text = Localization.GetString("CreateTitle", LocalResourceFile)
                cmdCreateUser.Text = Localization.GetString("cmdCreate", LocalResourceFile)
            Else
                lblRegisterHelp.Text += Localization.GetString("Required", Localization.SharedResourceFile)
                lblRegisterTitle.Text = Localization.GetString("RegisterTitle", LocalResourceFile)
                cmdCreateUser.Text = Localization.GetString("cmdRegister", LocalResourceFile)
                ctlUser.ShowPassword = False
                ctlUser.ShowUpdate = False
                ctlUser.User = User
                ctlUser.DataBind()
            End If
        End Sub

        Private Sub InitialiseUser()
            'Set UserName to authentication Token
            User.Username = UserToken.Replace("http://", "").TrimEnd("/"c)

            'Load any Profile properties that may have been returned
            UpdateProfile(User, False)

            'Set DisplayName to UserToken if null
            If String.IsNullOrEmpty(User.DisplayName) Then
                User.DisplayName = UserToken.Replace("http://", "").TrimEnd("/"c)
            End If

            'Parse DisplayName into FirstName/LastName
            If User.DisplayName.IndexOf(" "c) > 0 Then
                User.FirstName = User.DisplayName.Substring(0, User.DisplayName.IndexOf(" "c))
                User.LastName = User.DisplayName.Substring(User.DisplayName.IndexOf(" "c) + 1)
            End If

            'Set FirstName to Authentication Type (if null)
            If String.IsNullOrEmpty(User.FirstName) Then
                User.FirstName = AuthenticationType
            End If

            'Set FirstName to "User" (if null)
            If String.IsNullOrEmpty(User.LastName) Then
                User.LastName = "User"
            End If
        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' ShowPanel controls what "panel" is to be displayed
        ''' </summary>
        ''' <history>
        '''     [cnurse]    03/21/2006
        '''     [cnurse]    07/03/2007  Moved from Sign.ascx.vb
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Private Sub ShowPanel()
            Dim showLogin As Boolean = (PageNo = 0)
            Dim showRegister As Boolean = (PageNo = 1)
            Dim showPassword As Boolean = (PageNo = 2)
            Dim showProfile As Boolean = (PageNo = 3)

            pnlProfile.Visible = showProfile
            pnlPassword.Visible = showPassword
            pnlLogin.Visible = showLogin
            pnlRegister.Visible = showRegister
            pnlAssociate.Visible = showRegister

            Select Case PageNo
                Case 0
                    BindLogin()
                Case 1
                    BindRegister()
                Case 2
                    ctlPassword..UserId = UserId
                    ctlPassword.DataBind()
                Case 3
                    ctlProfile.UserId = UserId
                    ctlProfile.DataBind()
            End Select

        End Sub

        Private Sub UpdateProfile(ByVal objUser As UserInfo, ByVal update As Boolean)
            Dim bUpdateUser As Boolean
            If ProfileProperties.Count > 0 Then
                For Each key As String In ProfileProperties
                    Select Case key
                        Case "FirstName"
                            If objUser.FirstName <> ProfileProperties(key) Then
                                objUser.FirstName = ProfileProperties(key)
                                bUpdateUser = True
                            End If
                        Case "LastName"
                            If objUser.LastName <> ProfileProperties(key) Then
                                objUser.LastName = ProfileProperties(key)
                                bUpdateUser = True
                            End If
                        Case "Email"
                            If objUser.Email <> ProfileProperties(key) Then
                                objUser.Email = ProfileProperties(key)
                                bUpdateUser = True
                            End If
                        Case "DisplayName"
                            If objUser.DisplayName <> ProfileProperties(key) Then
                                objUser.DisplayName = ProfileProperties(key)
                                bUpdateUser = True
                            End If
                        Case Else
                            objUser.Profile.SetProfileProperty(key, ProfileProperties(key))
                    End Select
                Next
                If update Then
                    If bUpdateUser Then
                        UserController.UpdateUser(PortalId, objUser)
                    End If
                    ProfileController.UpdateUserProfile(objUser)
                End If
            End If
        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' ValidateUser runs when the user has been authorized by the data store.  It validates for
        ''' things such as an expiring password, valid profile, or missing DNN User Association
        ''' </summary>
        ''' <param name="objUser">The logged in User</param>
        ''' <param name="ignoreExpiring">Ignore the situation where the password is expiring (but not yet expired)</param>
        ''' <history>
        '''     [cnurse]    03/15/2006
        '''     [cnurse]    07/03/2007  Moved from Sign.ascx.vb
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Private Sub ValidateUser(ByVal objUser As UserInfo, ByVal ignoreExpiring As Boolean)
            Dim validStatus As UserValidStatus = UserValidStatus.VALID
            Dim strMessage As String = Null.NullString
            Dim expiryDate As DateTime = Null.NullDate

            If Not objUser.IsSuperUser Then
                validStatus = UserController.ValidateUser(objUser, PortalId, ignoreExpiring)
            End If

            UserId = objUser.UserID

            'Check if the User has valid Password/Profile
            Select Case validStatus
                Case UserValidStatus.VALID
                    'Set the Page Culture(Language) based on the Users Preferred Locale
                    If (Not objUser.Profile Is Nothing) AndAlso (Not objUser.Profile.PreferredLocale Is Nothing) Then
                        Localization.SetLanguage(objUser.Profile.PreferredLocale)
                    Else
                        Localization.SetLanguage(PortalSettings.DefaultLanguage)
                    End If

                    'Set the Authentication Type used
                    AuthenticationController.SetAuthenticationType(AuthenticationType)

                    'Complete Login
                    UserController.UserLogin(PortalId, objUser, PortalSettings.PortalName, AuthenticationLoginBase.GetIPAddress(), chkCookie.Checked)

                    ' redirect browser
                    Response.Redirect(RedirectURL, True)
                Case UserValidStatus.PASSWORDEXPIRED
                    strMessage = String.format(Localization.GetString("PasswordExpired", Me.LocalResourceFile), expiryDate.ToLongDateString)
                    AddLocalizedModuleMessage(strMessage, ModuleMessageType.YellowWarning, True)
                    PageNo = 2
                    pnlProceed.Visible = False
                Case UserValidStatus.PASSWORDEXPIRING
                    strMessage = String.format(Localization.GetString("PasswordExpiring", Me.LocalResourceFile), expiryDate.ToLongDateString)
                    AddLocalizedModuleMessage(strMessage, ModuleMessageType.YellowWarning, True)
                    PageNo = 2
                    pnlProceed.Visible = True
                Case UserValidStatus.UPDATEPASSWORD
                    AddModuleMessage("PasswordUpdate", ModuleMessageType.YellowWarning, True)
                    PageNo = 2
                    pnlProceed.Visible = False
                Case UserValidStatus.UPDATEPROFILE
                    'Admin has forced profile update
                    AddModuleMessage("ProfileUpdate", ModuleMessageType.YellowWarning, True)
                    PageNo = 3
            End Select

            ShowPanel()

        End Sub

#End Region

#Region "Event Handlers"

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Page_Init runs when the control is initialised
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        '''     [cnurse]    9/8/2004    Updated to reflect design changes for Help, 508 support
        '''                       and localisation
        '''     [cnurse]    07/08/2007  Moved from Sign.ascx.vb
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
            'Set the User Control Properties
            ctlUser.ID = "User"

            'Set the Profile Control Properties
            ctlPassword.ID = "Password"

            'Set the Profile Control Properties
            ctlProfile.ID = "Profile"

            'Override the redirected page title if page has loaded with ctl=Login
            If Not Request.QueryString("ctl") Is Nothing Then
                If Request.QueryString("ctl").ToLower = "login" Then
                    Dim myPage As DotNetNuke.Framework.CDefault
                    myPage = CType(Me.Page, CDefault)
                    If myPage.PortalSettings.LoginTabId = Me.TabId Or myPage.PortalSettings.LoginTabId = -1 Then
                        myPage.Title = Localization.GetString("ControlTitle_login", Me.LocalResourceFile)
                    End If
                End If
            End If

        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Page_Load runs when the control is loaded
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        '''     [cnurse]    9/8/2004    Updated to reflect design changes for Help, 508 support
        '''                       and localisation
        '''     [cnurse]    07/08/2007  Moved from Sign.ascx.vb
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

            ' Verify if portal has a customized login page
            If Not Null.IsNull(PortalSettings.LoginTabId) And IsAdminControl() Then
                ' login page exists and trying to access this control directly with url param -> not allowed
                Dim params(2) As String
                If Not String.IsNullOrEmpty(Request.QueryString("returnUrl")) Then
                    params(0) = "returnUrl=" & Request.QueryString("returnUrl")
                End If
                If Not String.IsNullOrEmpty(Request.QueryString("username")) Then
                    params(1) = "username=" & Request.QueryString("username")
                End If
                If Not String.IsNullOrEmpty(Request.QueryString("verificationcode")) Then
                    params(2) = "verificationcode=" & Request.QueryString("verificationcode")
                End If
                Response.Redirect(NavigateURL(PortalSettings.LoginTabId, "", params))
            End If

            If Not Request.IsAuthenticated Then
                If Page.IsPostBack = False Then
                    Try
                        PageNo = 0
                    Catch
                        'control not there
                    End Try
                End If

                ShowPanel()

            Else ' user is already authenticated

                ' if a Login Page has not been specified for the portal
                If IsAdminControl() Then
                    ' redirect to current page
                    Response.Redirect(NavigateURL(), True)
                Else ' make module container invisible if user is not a page admin
                    If Not DotNetNuke.Security.Permissions.TabPermissionController.HasTabPermission("EDIT") Then
                        ContainerControl.Visible = False
                    End If
                End If

            End If

            trCaptcha.Visible = UseCaptcha

            If UseCaptcha Then
                ctlCaptcha.ErrorMessage = Localization.GetString("InvalidCaptcha", Localization.SharedResourceFile)
                ctlCaptcha.Text = Localization.GetString("CaptchaText", Localization.SharedResourceFile)
            End If

        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' cmdAssociate_Click runs when the associate button is clicked
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        '''     [cnurse]    07/12/2007    Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Protected Sub cmdAssociate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAssociate.Click
            If (UseCaptcha And ctlCaptcha.IsValid) OrElse (Not UseCaptcha) Then
                Dim loginStatus As UserLoginStatus = UserLoginStatus.LOGIN_FAILURE
                Dim objUser As UserInfo = UserController.ValidateUser(PortalId, txtUsername.Text, txtPassword.Text, "DNN", "", PortalSettings.PortalName, AuthenticationLoginBase.GetIPAddress(), loginStatus)

                If loginStatus = UserLoginStatus.LOGIN_SUCCESS Then
                    'Assocate alternate Login with User and proceed with Login
                    AuthenticationController.AddUserAuthentication(objUser.UserID, AuthenticationType, UserToken)

                    If Not objUser Is Nothing Then
                        UpdateProfile(objUser, True)
                    End If

                    ValidateUser(objUser, True)
                Else
                    AddModuleMessage("AssociationFailed", ModuleMessageType.RedError, True)
                End If

            End If
        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' cmdCreateUser runs when the register (as new user) button is clicked
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        '''     [cnurse]    07/12/2007    Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Protected Sub cmdCreateUser_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCreateUser.Click
            'Generate a random password for the user
            User.Membership.Password = UserController.GeneratePassword()

            If AutoRegister Then
                ctlUser.User = User

                'Call the Create User method of the User control so that it can create
                'the user and raise the appropriate event(s)
                ctlUser.CreateUser()
            Else
                If ctlUser.IsValid Then
                    'Call the Create User method of the User control so that it can create
                    'the user and raise the appropriate event(s)
                    ctlUser.CreateUser()
                End If
            End If
        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' cmdPassword_Click runs when the Password Reminder button is clicked
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        '''     [cnurse]    03/21/2006  Created
        '''     [cnurse]    07/03/2007  Moved from Sign.ascx.vb
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Private Sub cmdPassword_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles cmdPassword.Click
            Response.Redirect(NavigateURL("SendPassword"), True)
        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' cmdProceed_Click runs when the Proceed Anyway button is clicked
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        '''     [cnurse]    06/30/2006  Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Private Sub cmdProceed_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdProceed.Click
            Dim _User As UserInfo = ctlPassword.User
            ValidateUser(_User, True)
        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' cmdRegister_Click runs when the register button is clicked
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        '''     [cnurse]    9/24/2004    Updated to reflect design changes for Help, 508 support
        '''                       and localisation
        '''     [cnurse]    12/11/2005  Updated to reflect abstraction of Membership
        '''     [cnurse]    07/03/2007  Moved from Sign.ascx.vb
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Private Sub cmdRegister_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdRegister.Click

            If PortalSettings.UserRegistration <> PortalRegistrationType.NoRegistration Then
                Dim ReturnUrl As String = HttpContext.Current.Request.RawUrl
                If ReturnUrl.IndexOf("?returnurl=") <> -1 Then
                    ReturnUrl = ReturnUrl.Substring(0, ReturnUrl.IndexOf("?returnurl="))
                End If
                ReturnUrl = HttpUtility.UrlEncode(ReturnUrl)

                If PortalSettings.UserTabId <> -1 Then
                    ' user defined tab
                    Response.Redirect(NavigateURL(PortalSettings.UserTabId, "", "returnurl=" & ReturnUrl), True)
                Else
                    ' portal tab
                    If PortalSettings.HomeTabId <> -1 Then
                        Response.Redirect(NavigateURL(PortalSettings.HomeTabId, "Register", "returnurl=" & ReturnUrl), True)
                    Else
                        Response.Redirect(NavigateURL("Register", "returnurl=" & ReturnUrl), True)
                    End If
                End If
            End If

        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' PasswordUpdated runs when the password is updated
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        '''     [cnurse]    03/15/2006  Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Private Sub PasswordUpdated(ByVal sender As Object, ByVal e As Users.Password.PasswordUpdatedEventArgs) Handles ctlPassword.PasswordUpdated

            Dim status As PasswordUpdateStatus = e.UpdateStatus

            If status = PasswordUpdateStatus.Success Then
                AddModuleMessage("PasswordChanged", ModuleMessageType.GreenSuccess, True)

                'Authorize User
                Dim _User As UserInfo = ctlPassword.User
                _User.Membership.LastPasswordChangeDate = Now()
                _User.Membership.UpdatePassword = False
                ValidateUser(_User, True)
            Else
                AddModuleMessage(status.ToString(), ModuleMessageType.RedError, True)
            End If

        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' ProfileUpdated runs when the profile is updated
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        '''     [cnurse]    03/16/2006  Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Private Sub ProfileUpdated(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctlProfile.ProfileUpdated
            'Authorize User
            ValidateUser(ctlProfile.User, True)
        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' UserAuthenticated runs when the user is authenticated by one of the child
        ''' Authentication controls
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        '''     [cnurse]    07/10/2007  Created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Private Sub UserAuthenticated(ByVal sender As Object, ByVal e As UserAuthenticatedEventArgs)
            LoginStatus = e.LoginStatus

            'Check the Login Status
            Select Case LoginStatus
                Case UserLoginStatus.LOGIN_USERNOTAPPROVED
                    Select Case e.Message
                        Case "EnterCode"
                            AddModuleMessage(e.Message, ModuleMessageType.YellowWarning, True)
                        Case "InvalidCode", "UserNotAuthorized"
                            AddModuleMessage(e.Message, ModuleMessageType.RedError, True)
                        Case Else
                            AddLocalizedModuleMessage(e.Message, ModuleMessageType.RedError, True)
                    End Select
                Case UserLoginStatus.LOGIN_USERLOCKEDOUT
                    AddModuleMessage("UserLockedOut", ModuleMessageType.RedError, True)
                    ' notify administrator about account lockout ( possible hack attempt )
                    Dim Custom As New ArrayList
                    Custom.Add(e.UserToken)
                    Mail.SendMail(PortalSettings.Email, PortalSettings.Email, "", _
                        Localization.GetSystemMessage(PortalSettings, "EMAIL_USER_LOCKOUT_SUBJECT", Localization.GlobalResourceFile, Custom), _
                        Localization.GetSystemMessage(PortalSettings, "EMAIL_USER_LOCKOUT_BODY", Localization.GlobalResourceFile, Custom), _
                        "", "", "", "", "", "")
                Case UserLoginStatus.LOGIN_FAILURE
                    'A Login Failure can mean one of two things:
                    '  1 - User was authenticated by the Authentication System but is not "affiliated" with a DNN Account
                    '  2 - User was not authenticated
                    If e.Authenticated Then
                        PageNo = 1
                        AuthenticationType = e.AuthenticationType
                        AutoRegister = e.AutoRegister
                        ProfileProperties = e.Profile
                        UserToken = e.UserToken

                        ShowPanel()
                    Else
                        If String.IsNullOrEmpty(e.Message) Then
                            AddModuleMessage("LoginFailed", ModuleMessageType.RedError, True)
                        Else
                            Me.AddLocalizedModuleMessage(e.Message, ModuleMessageType.RedError, True)
                        End If
                    End If
                Case Else
                    If e.User IsNot Nothing Then
                        'First update the profile (if any properties have been passed)
                        AuthenticationType = e.AuthenticationType
                        ProfileProperties = e.Profile

                        UpdateProfile(e.User, True)

                        ValidateUser(e.User, False)
                    End If
            End Select

        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' UserCreateCompleted runs when a new user has been Created
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        '''     [cnurse]    07/12/2007    created
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Private Sub UserCreateCompleted(ByVal sender As Object, ByVal e As Entities.Modules.UserUserControlBase.UserCreatedEventArgs) Handles ctlUser.UserCreateCompleted
            Dim strMessage As String = ""

            Try
                If e.CreateStatus = UserCreateStatus.Success Then
                    'Assocate alternate Login with User and proceed with Login
                    AuthenticationController.AddUserAuthentication(e.NewUser.UserID, AuthenticationType, UserToken)

                    strMessage = CompleteUserCreation(e.CreateStatus, e.NewUser, e.Notify, True)
                    If (String.IsNullOrEmpty(strMessage)) Then
                        'First update the profile (if any properties have been passed)
                        UpdateProfile(e.NewUser, True)

                        ValidateUser(e.NewUser, True)
                    End If
                Else
                    AddLocalizedModuleMessage(UserController.GetUserCreateStatus(e.CreateStatus), ModuleMessageType.RedError, True)
                End If

            Catch exc As Exception    'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

#End Region
    End Class

End Namespace

 

 

 

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Configure DNN environment question?Configure DNN environment question?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out