Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

Maximum ASP
  Ads  
Iron Speed Designer is a software development tool for building database, reporting, and forms applications for .NET without hand-coding.
 


  Sponsors  

Meet Our Sponsors

eUKhost.com is commited to offer exceptional UK Windows Web Hosting solutions with quality 24x7 technical support.Our plans support ASP.Net, ASP, ASP.NET Ajax extensions, XML, MSSQL, MySQL, PHP,DNN, multiple domains and Shared SSL as standard.
SmarterTools
The Official Microsoft ASP.NET Website
Portal Webhosting - Hosting For Developers
Red-Gate Software
MaximumASP
 


DotNetNuke Forums
 
  Forum  DotNetNuke® Pro...  Authentication ...  Loop Problem
Previous Previous
 
Next Next
New Post 7/11/2007 8:23 AM
User is offline Ambiorex
3 posts
10th Ranked


Loop Problem 

Hi All,

I've been testing the AD Authentication for usage in an Intranet environment for a while, but I kept running into loop problems.
Finally I decided to adjuste some of the code myself. 

The changes I made, let me login on all the different portals, with the same AD account. Maybe someone has some use for it, so here it is...


One BIG remark: 

This code does not let user logout! Make sure you choose your Admin and Host account carefully (they should be part of the domain)!  

Initially I installed DNN 4.4.1, and added the AD Fix (Little remark: I do use Integrated authentication on the entire site, not only the WindowsSignin page!)


Here are the changes I made so far:


OnAuthenticateRequest in AythenticationModule.vb:
=================================================

Replaced the entire sub with:

        Public Sub OnAuthenticateRequest(ByVal s As Object, ByVal e As EventArgs)
            Dim _portalSettings As PortalSettings = Common.GetPortalSettings
            Dim config As Authentication.Configuration = Authentication.Configuration.GetConfig()

            If config.WindowsAuthentication Then
                Dim Request As HttpRequest = HttpContext.Current.Request
                Dim Response As HttpResponse = HttpContext.Current.Response

                Dim blnWinLogon As Boolean = (Request.RawUrl.ToLower.IndexOf((AUTHENTICATION_LOGON_PAGE).ToLower) > -1)
                Dim blnWinLogoff As Boolean = (Request.RawUrl.ToLower.IndexOf((AUTHENTICATION_LOGOFF_PAGE).ToLower) > -1)

                ' When on the login page, alsway's login, no matter what!
                If (blnWinLogon) Then
                    ' Login
                    Dim objAuthenticationController As AuthenticationController = New AuthenticationController()
                    objAuthenticationController.AuthenticationLogon()
                    AuthenticationController.SetStatus(_portalSettings.PortalId, AuthenticationStatus.WinLogon)
                    'Redirect to the home page
                    Response.Redirect(Request.RawUrl, True)
                End If

                'When logging off, alway's log off, no matter what!
                If (blnWinLogoff) Then
                    ' Logoff
                    Dim objAuthentication As New AuthenticationController
                    objAuthentication.AuthenticationLogoff()
                    'Redirect to the home page
                    Response.Redirect(Request.RawUrl, True)
                End If

                Dim currentAuthenticationStatus As AuthenticationStatus = AuthenticationController.GetStatus(_portalSettings.PortalId)
                Select Case currentAuthenticationStatus
                    Case AuthenticationStatus.Undefined
                        'Redirect to the login page
                        Response.Redirect(GetUrlWindowsSigninPage, True)
                    Case AuthenticationStatus.WinLogon
                        'User is logged in, do nothing
                    Case AuthenticationStatus.WinLogoff
                        'User is logging of, should not reach this
                        'Response.Redirect(GetUrlWindowsLogoffPage, True)
                    Case AuthenticationStatus.WinProcess
                        'Redirect to the login page
                        Response.Redirect(GetUrlWindowsSigninPage, True)
                End Select


            End If

        End Sub

        Private Function GetUrlWindowsSigninPage() As String

            'Create the return variable
            Dim url As String

            ' Get some needed settings
            Dim _portalSettings As PortalSettings = Common.GetPortalSettings
            Dim Request As HttpRequest = HttpContext.Current.Request
            Dim Response As HttpResponse = HttpContext.Current.Response

            If Request.ApplicationPath = "/" Then
                url = "/Admin/Security/" + AUTHENTICATION_LOGON_PAGE + "?tabid=" & _portalSettings.ActiveTab.TabID.ToString
            Else
                url = Request.ApplicationPath & "/Admin/Security/" + AUTHENTICATION_LOGON_PAGE + "?tabid=" & _portalSettings.ActiveTab.TabID.ToString
            End If

            Return url
        End Function


CreateUser in AspNetMembershipProvider:
=======================================

Removed the check on the password. This would check failes if the user allready exists in the database, but not for this portal:

 ' the username exists so we should now verify the password
        'If ValidateUser(objVerifyUser.PortalID, user.Username, user.Membership.Password) Then
  ...
  'Keep the existing code
  ...
        'Else
  ' not the same person - prevent registration
  'createStatus = UserCreateStatus.UsernameAlreadyExists
 'End If
 
GetStatus & SetStatus in AuthenticationController:
==================================================

Add a unique identifier for the AD user to the name of the cookie.
This would avoid the 'loop' when a users is Authenticated and the cookie is not yet expired.

            Dim strUserName As String = HttpContext.Current.Request.LogonUserIdentity.Name
            Dim authCookies As String = AUTHENTICATION_STATUS_KEY & "." & PortalID.ToString & "." & strUserName

 



It would be great if somebody could changes this code to enable the logoff...

 
Previous Previous
 
Next Next
  Forum  DotNetNuke® Pro...  Authentication ...  Loop Problem
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


Venexus, Inc.
Need custom a custom DotNetNuke module? From module planning to deployment, including training and support, Venexus developers deliver end-to-end web solutions on time and on budget.
www.venexus.com
Bring2mind
Document Centric DNN Module Solutions
www.bring2mind.net
WEBPC™ DotNetNuke® sites for Small Business
WEBPC™ are internet consultants and web hosters catering to the small business market.
www.webpc.biz

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP