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

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsAuthenticationAuthenticationConsequences of Removing Domain From UserName?Consequences of Removing Domain From UserName?
Previous
 
Next
New Post
8/8/2007 11:58 AM
 
Hello,

I have recompiled DNN sources according to your directions and almost everything works :)...
One thing is - one a while, usually randomly - I got the exception - DNN directs me to link 'http://dnnhost/Install.aspx?mode=upgrade' and error message is:
***
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
DotNetNuke.Security.Authentication.Configuration.GetConfig() +16
DotNetNuke.HttpModules.AuthenticationModule.OnAuthenticateRequest(Object s, EventArgs e) +25
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
***

I am guessing that the problem might be in a way I have 'installed' those recompiled .dll's - i just copied them from \bin directory in VS solution to \bin in DNN.
Has anybody any idea how to fix this issue ?

TIA

Lukasz

Lukasz Kuszaj lkuszaj@ndci.com
 
New Post
8/10/2007 4:23 PM
 

The error would be similar to having a null user object.  If this is an existing DB (or you have an existing account already in the database) have you removed the domain from the exiting logins in the user tables? 

 
New Post
11/16/2007 6:08 PM
 

Code changes needed to update for 4.6.2 (should apply to 4.7.0 also):

ADSI Changes
----------------------------------------------------
Settings.aspx
- Add checkbox to allow setting domain trimming
<tr>
    <td class="SubHead" width="200"><dnn:label id="plStripDomainName" runat="server" controlname="chkStripDomainName" text="Strip Domain?" /></td>
    <td valign="top"><asp:CheckBox ID="chkStripDomainName" runat="server" CssClass="NormalTextBox" /></td>
</tr>


Settings.aspx.vb
- Change Update Config in UpdateSettings to include Strip Domain value
Public Overrides Sub UpdateSettings()
...
    Configuration.UpdateConfig(_portalSettings.PortalId, Me.chkAuthentication.Checked, Me.txtRootDomain.Text, Me.txtEmailDomain.Text, Me.txtUserName.Text, Me.txtPassword.Text, Me.chkSynchronizeRole.Checked, Me.chkSynchronizePassword.Checked, Me.chkStripDomainName.Checked, providerTypeName, authenticationType)
...
End Sub

- Add code to handle chkStripDomainName
Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
...
    chkAuthentication.Checked = config.WindowsAuthentication
    chkSynchronizeRole.Checked = config.SynchronizeRole
    chkSynchronizePassword.Checked = config.SynchronizePassword
    chkStripDomainName.Checked = config.StripDomainName
    txtRootDomain.Text = config.RootDomain
    txtUserName.Text = config.UserName
    txtEmailDomain.Text = config.EmailDomain
...
End Sub

AuthenticationController.vb
- Check setting and apply changes to UserName; fix references in rest of Sub
- Also includes authentication redirect fix
Public Sub AuthenticationLogon()
    Dim _config As Configuration = Configuration.GetConfig()

    Dim objAuthUserController As New Authentication.ActiveDirectory.UserController
    Dim authCookies As String = Configuration.AUTHENTICATION_KEY & "_" & _portalSettings.PortalId.ToString
    Dim LoggedOnUserName As String = HttpContext.Current.Request.ServerVariables(Configuration.LOGON_USER_VARIABLE)

    If LoggedOnUserName.Length > 0 Then
 Dim UserName As String = LoggedOnUserName

 If _config.StripDomainName Then
     UserName = DotNetNuke.Authentication.ActiveDirectory.ADSI.Utilities.TrimUserDomainName(UserName)
 End If

 Dim objDNNUser As DotNetNuke.Entities.Users.UserInfo
 Dim objAuthUser As Authentication.ActiveDirectory.UserInfo

 Dim intUserId As Integer

 objDNNUser = DotNetNuke.Entities.Users.UserController.GetUserByName(_portalSettings.PortalId, UserName, False)

 If Not objDNNUser Is Nothing Then
     intUserId = objDNNUser.UserID

     ' Synchronize role membership if it's required in settings
     If _config.SynchronizeRole Then
  SynchronizeRoles(UserName, intUserId)
     End If
 Else
     ' User not exists in DNN database, obtain user info from provider to add new
     objAuthUser = objAuthUserController.GetUser(LoggedOnUserName)
     objDNNUser = CType(objAuthUser, DotNetNuke.Entities.Users.UserInfo)

     UserName = objDNNUser.Username
     If _config.StripDomainName Then
  UserName = DotNetNuke.Authentication.ActiveDirectory.ADSI.Utilities.TrimUserDomainName(UserName)
     End If
     objDNNUser.Username = UserName

     If Not objAuthUser Is Nothing Then
  Dim createStatus As UserCreateStatus = objAuthUserController.AddDNNUser(objAuthUser)
  intUserId = objAuthUser.UserID
  SetStatus(_portalSettings.PortalId, AuthenticationStatus.WinLogon)
     End If
 End If

 If intUserId > 0 Then
     FormsAuthentication.SetAuthCookie(Convert.ToString(UserName), True)

     'check if user has supplied custom value for expiration

     Dim PersistentCookieTimeout As Integer
     If Not Config.GetSetting("PersistentCookieTimeout") Is Nothing Then
  PersistentCookieTimeout = Integer.Parse(Config.GetSetting("PersistentCookieTimeout"))
  'only use if non-zero, otherwise leave as asp.net value
  If PersistentCookieTimeout <> 0 Then
      'locate and update cookie
      Dim authCookie As String = FormsAuthentication.FormsCookieName
      For Each cookie As String In HttpContext.Current.Response.Cookies
   If cookie.Equals(authCookie) Then
       HttpContext.Current.Response.Cookies(cookie).Expires = DateTime.Now.AddMinutes(PersistentCookieTimeout)
   End If
      Next
  End If
     End If

     SetStatus(_portalSettings.PortalId, AuthenticationStatus.WinLogon)

     ' Get ipAddress for eventLog
     Dim ipAddress As String = ""
     If Not HttpContext.Current.Request.UserHostAddress Is Nothing Then
  ipAddress = HttpContext.Current.Request.UserHostAddress
     End If

     Dim objEventLog As New Services.Log.EventLog.EventLogController
     Dim objEventLogInfo As New Services.Log.EventLog.LogInfo
     objEventLogInfo.AddProperty("IP", ipAddress)
     objEventLogInfo.LogPortalID = _portalSettings.PortalId
     objEventLogInfo.LogPortalName = _portalSettings.PortalName
     objEventLogInfo.LogUserID = intUserId
     objEventLogInfo.LogUserName = UserName
     objEventLogInfo.AddProperty("WindowsAuthentication", "True")
     objEventLogInfo.LogTypeKey = "LOGIN_SUCCESS"

     objEventLog.AddLog(objEventLogInfo)

 End If
    Else
 ' Not Windows Authentication
    End If

    ' params "logon=windows" does nothing, just to force page to be refreshed
    'Dim strURL As String = NavigateURL(_portalSettings.ActiveTab.TabID, "", "logon=windows")
    'Updated to redirect to querrystring passed in prior to authentication
    Dim querystringparams As String = "logon=" & DateTime.Now.Ticks.ToString()
    Dim strURL As String = NavigateURL(_portalSettings.ActiveTab.TabID, String.Empty, querystringparams)
    If Not HttpContext.Current.Request.Cookies("DNNReturnTo" + _portalSettings.PortalId.ToString()) Is Nothing Then
 querystringparams = HttpContext.Current.Request.Cookies("DNNReturnTo" + _portalSettings.PortalId.ToString()).Value
 If querystringparams <> String.Empty And querystringparams.IndexOf("WindowsSignin.aspx") < 0 Then strURL = querystringparams
    End If
    HttpContext.Current.Response.Redirect(strURL, True)


End Sub


Public Function ProcessFormAuthentication(ByVal LoggedOnUserName As String, ByVal LoggedOnPassword As String) As UserInfo  'DotNetNuke.Entities.Users.UserInfo
    Dim _config As Configuration = Configuration.GetConfig()
    Dim objAuthUserController As New UserController
    Dim objUsers As New DotNetNuke.Entities.Users.UserController

    If _config.WindowsAuthentication Then
 Dim UserName As String = LoggedOnUserName

 If _config.StripDomainName Then
     UserName = DotNetNuke.Authentication.ActiveDirectory.ADSI.Utilities.TrimUserDomainName(UserName)
 End If

 Dim objAuthUser As UserInfo = objAuthUserController.GetUser(UserName, LoggedOnPassword)
 Return objAuthUser
    End If
    Return Nothing

End Function

Public Function GetDNNUser(ByVal PortalID As Integer, ByVal LoggedOnUserName As String) As DotNetNuke.Entities.Users.UserInfo
    Dim _config As Configuration = Configuration.GetConfig()
    Dim objUser As DotNetNuke.Entities.Users.UserInfo

    Dim UserName As String = LoggedOnUserName

    If _config.StripDomainName Then
 UserName = DotNetNuke.Authentication.ActiveDirectory.ADSI.Utilities.TrimUserDomainName(UserName)
    End If

    'TODO: Check the new concept of 3.0 for user in multi portal
    ' check if this user exists in database for any portal
    objUser = DotNetNuke.Entities.Users.UserController.GetUserByName(Null.NullInteger, UserName, False)
    If Not objUser Is Nothing Then
 ' Check if user exists in this portal
 If DotNetNuke.Entities.Users.UserController.GetUserByName(PortalID, UserName, False) Is Nothing Then
     ' The user does not exist in this portal - add them
     objUser.PortalID = PortalID
     DotNetNuke.Entities.Users.UserController.CreateUser(objUser)
 End If
 Return objUser
    Else
 ' the user does not exist
 Return Nothing
    End If

End Function

 

Configuration.vb
- Add code for StripDomainName
Public Class Configuration
...
        Private mPortalId As Integer
        Private mWindowsAuthentication As Boolean = False
        Private mRootDomain As String = ""
        Private mUserName As String = ""
        Private mPassword As String = ""
        Private mSynchronizeRole As Boolean = False
        Private mSynchronizePassword As Boolean = False ' reserve for future feature
        Private mStripDomainName As Boolean = False
        Private mProviderTypeName As String = DefaultProviderTypeName
        Private mAuthenticationType As String = DefaultAuthenticationType
        Private mEmailDomain As String = DefaultEmailDomain
...

        Sub New()
 ...
     mWindowsAuthentication = CType(Null.GetNull(settings("AD_WindowsAuthentication"), mWindowsAuthentication), Boolean)
     mSynchronizeRole = CType(Null.GetNull(settings("AD_SynchronizeRole"), mSynchronizeRole), Boolean)
     mSynchronizePassword = CType(Null.GetNull(settings("AD_SynchronizePassword"), mSynchronizePassword), Boolean)
     mStripDomainName = CType(Null.GetNull(settings("AD_StripDomainName"), mStripDomainName), Boolean)
     mRootDomain = CType(Null.GetNull(settings("AD_RootDomain"), mRootDomain), String)
     mEmailDomain = CType(Null.GetNull(settings("AD_EmailDomain"), mEmailDomain), String)
     mUserName = CType(Null.GetNull(settings("AD_UserName"), mUserName), String)
     mProviderTypeName = CType(Null.GetNull(settings("AD_ProviderTypeName"), mProviderTypeName), String)
     mAuthenticationType = CType(Null.GetNull(settings("AD_AuthenticationType"), mAuthenticationType), String)
     mPassword = objSecurity.Decrypt(AUTHENTICATION_KEY, CType(Null.GetNull(settings("AD_AuthenticationPassword"), mPassword.ToString), String))
 ...
 End Sub
 ...
 Public Shared Sub UpdateConfig(ByVal PortalID As Integer, _
         ByVal WindowsAuthentication As Boolean, _
         ByVal RootDomain As String, _
         ByVal EmailDomain As String, _
         ByVal AuthenticationUserName As String, _
         ByVal AuthenticationPassword As String, _
         ByVal SynchronizeRole As Boolean, _
         ByVal SynchronizePassword As Boolean, _
         ByVal StripDomainName As Boolean, _
         ByVal ProviderTypeName As String, _
         ByVal AuthenticationType As String)
 ...
            objModules.UpdateModuleSetting(intModuleId, "AD_WindowsAuthentication", WindowsAuthentication.ToString)
            objModules.UpdateModuleSetting(intModuleId, "AD_SynchronizeRole", SynchronizeRole.ToString)
            objModules.UpdateModuleSetting(intModuleId, "AD_SynchronizePassword", SynchronizePassword.ToString)
            objModules.UpdateModuleSetting(intModuleId, "AD_StripDomainName", StripDomainName.ToString)
            objModules.UpdateModuleSetting(intModuleId, "AD_RootDomain", RootDomain)
            objModules.UpdateModuleSetting(intModuleId, "AD_EmailDomain", EmailDomain)
            objModules.UpdateModuleSetting(intModuleId, "AD_UserName", AuthenticationUserName)
            objModules.UpdateModuleSetting(intModuleId, "AD_ProviderTypeName", ProviderTypeName)
            objModules.UpdateModuleSetting(intModuleId, "AD_AuthenticationType", AuthenticationType)
 ...
 End Sub

-- Add New Property 
 ''' -------------------------------------------------------------------
 ''' <summary>
 '''     Determin if Domain Name should be stripped from UserName
 ''' </summary>
 ''' <remarks>
 '''     In an environment with single domain or unique username across domains
 ''' </remarks>
 ''' <history>
 '''     [jhoskins] 10/10/2007 Created
 ''' </history>
 ''' -------------------------------------------------------------------
 Public ReadOnly Property StripDomainName() As Boolean
     Get
  Return mStripDomainName
     End Get
 End Property


UserController.vb
-- Set authentication type so that we can get to it later
Public Function AddDNNUser(ByVal AuthenticationUser As UserInfo) As UserCreateStatus
    Dim _portalSettings As PortalSettings = PortalController.GetCurrentPortalSettings
    Dim objSecurity As New PortalSecurity
    DotNetNuke.Services.Authentication.AuthenticationController.SetAuthenticationType("ActiveDirectory")
...
End Function


AuthenticationModule.vb
- Authentication redirect fix
Public Sub OnAuthenticateRequest(ByVal s As Object, ByVal e As EventArgs)
...
    If config.WindowsAuthentication Then
 Dim authStatus As AuthenticationStatus = AuthenticationController.GetStatus(_portalSettings.PortalId)
 Dim blnWinLogon As Boolean = (Request.RawUrl.ToLower.IndexOf((Configuration.AUTHENTICATION_LOGON_PAGE).ToLower) > -1)
 Dim blnWinLogoff As Boolean = (authStatus = AuthenticationStatus.WinLogon) _
     AndAlso (Request.RawUrl.ToLower.IndexOf((Configuration.AUTHENTICATION_LOGOFF_PAGE).ToLower) > -1)

 If (authStatus = AuthenticationStatus.Undefined) Then  'OrElse (blnWinLogon) Then
     AuthenticationController.SetStatus(_portalSettings.PortalId, AuthenticationStatus.WinProcess)
     Dim url As String
     If Request.ApplicationPath = "/" Then
  url = Configuration.AUTHENTICATION_PATH & Configuration.AUTHENTICATION_LOGON_PAGE & "?tabid=" & _portalSettings.ActiveTab.TabID.ToString
     Else
  url = Request.ApplicationPath & Configuration.AUTHENTICATION_PATH & Configuration.AUTHENTICATION_LOGON_PAGE & "?tabid=" & _portalSettings.ActiveTab.TabID.ToString
     End If
     Try
  Dim refUrl As String = Request.RawUrl
  Response.Clear()
  Response.Cookies("DNNReturnTo" & _portalSettings.PortalId.ToString()).Value = refUrl
  Response.Cookies("DNNReturnTo" & _portalSettings.PortalId.ToString()).Path = "/"
  Response.Cookies("DNNReturnTo" & _portalSettings.PortalId.ToString()).Expires = DateTime.Now.AddMinutes(2)
     Catch
     End Try
     Response.Redirect(url)
 ElseIf (Not authStatus = AuthenticationStatus.WinLogoff) AndAlso blnWinLogoff Then
     Dim objAuthentication As New AuthenticationController
     objAuthentication.AuthenticationLogoff()
 ElseIf (authStatus = AuthenticationStatus.WinLogoff) AndAlso blnWinLogon Then ' has been logoff before
     AuthenticationController.SetStatus(_portalSettings.PortalId, AuthenticationStatus.Undefined)
     Response.Redirect(Request.RawUrl)
 End If

    End If
...
End Sub

 

Core Changes
----------------------------------------------------
AspNetMembershipProvider.vb

-- Checks for provider type.  If AD, ignores password in AD - this will also fix multiple sites with AD user issues.
Public Overrides Function CreateUser(ByRef user As UserInfo) As UserCreateStatus
    Dim createStatus As UserCreateStatus
    Dim authType As DotNetNuke.Services.Authentication.AuthenticationInfo = DotNetNuke.Services.Authentication.AuthenticationController.GetAuthenticationType()
    Dim isADSIProvider As Boolean = False
    Dim ProviderTypeName As String = String.Empty
    If Not authType Is Nothing Then ProviderTypeName = authType.AuthenticationType
    isADSIProvider = (ProviderTypeName.IndexOf("ActiveDirectory") >= 0)

...
    Else
 ' the username exists so we should now verify the password
 If isADSIProvider Or ValidateUser(objVerifyUser.PortalID, user.Username, user.Membership.Password) Then
...
End Function

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsAuthenticationAuthenticationConsequences of Removing Domain From UserName?Consequences of Removing Domain From UserName?


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