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
9/26/2006 3:38 PM
 

What would be the ramifications of removing the domain name from the user name?  Just wondering if I am missing anything that would be impacted by doing this.  I have not noticed anything obvious in the tests I have done.

I have successfully modified the code to do this including an appSetting in web.config to toggle it.  I can share the modifications (only a couple of places need changes) if there is anyone interrested.

 
New Post
9/29/2006 1:20 PM
 

That can be very useful...  if you can give some more info on what you did I think that ‘ll be great.

 

 
New Post
9/29/2006 2:57 PM
 

Change made in 3 files (plus web config).

web.config
-- Add key to appSettings
<add key="AuthenticationStripDomain" value="true" />

DotNetNuke.Library/Shared
Globals.vb
-- Add in from ADSI Componant due to need for this function in other places
Public Function TrimUserDomainName(ByVal UserName As String) As String
    Dim strReturn As String
    If UserName.IndexOf("\") > -1 Then
        strReturn = Right(UserName, UserName.Length - (UserName.IndexOf("\") + 1))
    ElseIf UserName.IndexOf("@") > -1 Then
        strReturn = Left(UserName, UserName.IndexOf("@"))
    Else
        strReturn = UserName
    End If
    Return strReturn
End Function

DotNetNuke.Library/Components/Authentication
AuthenticationController.vb
-- Modify AuthenticationLogon() to check for appsetting and remove domain from login name
Public Sub AuthenticationLogon()
   Dim _config As Authentication.Configuration = Authentication.Configuration.GetConfig()

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

   If LoggedOnUserName.Length > 0 Then
       Dim UserName As String = LoggedOnUserName
       If Not Config.GetSetting("AuthenticationStripDomain") Is Nothing Then
           If Config.GetSetting("AuthenticationStripDomain") = "true" Then
               UserName = DotNetNuke.Common.Globals.TrimUserDomainName(UserName)
           End If
       End If
       Dim objDNNUser As DotNetNuke.Entities.Users.UserInfo
       Dim objAuthUser As Authentication.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
               objAuthUser = objAuthUserController.GetUser(UserName)

               ' user object might be in simple version in none active directory network
               If Not objAuthUser.GUID.Length = 0 Then
                   objAuthUser.UserID = intUserId
                   UserController.AddUserRoles(_portalSettings.PortalId, objAuthUser)
               End If
           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 Not Config.GetSetting("AuthenticationStripDomain") Is Nothing Then
               If Config.GetSetting("AuthenticationStripDomain") = "true" Then
                   UserName = DotNetNuke.Common.Globals.TrimUserDomainName(UserName)
               End If
           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

           .......

           ' Get ipAddress for eventLog
           ......

           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"

         ......
.......

End Sub

HttpModule.DNNMembership
DNNMembershipModule.vb
-- Modify OnAuthenticateRequest() to check for appsetting and remove domain from Context.User.Identity.Name 
Public Sub OnAuthenticateRequest(ByVal s As Object, ByVal e As EventArgs)
   Dim Context As HttpContext = CType(s, HttpApplication).Context
   Dim Request As HttpRequest = Context.Request
   Dim Response As HttpResponse = Context.Response

   'First check if we are upgrading/installing
   If Request.Url.LocalPath.EndsWith("Install.aspx") Then
       Exit Sub
   End If

   'exit if a request for a .net mapping that isn't a content page is made i.e. axd
   If Request.Url.LocalPath.ToLower.EndsWith(".aspx") = False _
           AndAlso Request.Url.LocalPath.ToLower.EndsWith(".asmx") = False Then
       Exit Sub
   End If
  
   ' Obtain PortalSettings from Current Context
   Dim _portalSettings As PortalSettings = PortalController.GetCurrentPortalSettings

   If Request.IsAuthenticated = True And Not _portalSettings Is Nothing Then
       Dim arrPortalRoles() As String
       Dim objRoleController As New RoleController
       Dim UserName As String = Context.User.Identity.Name
       If Not Config.GetSetting("AuthenticationStripDomain") Is Nothing Then
           If Config.GetSetting("AuthenticationStripDomain") = "true" Then
               UserName = DotNetNuke.Common.Globals.TrimUserDomainName(UserName)
           End If
       End If

       Dim objUser As UserInfo = UserController.GetCachedUser(_portalSettings.PortalId, UserName)
      ......

 
New Post
10/25/2006 3:01 PM
 

I like the idea!  That would make it sooooo much easier.  A couple of questions though, before I dive into learning how to re-compile the entire program...

1.  How well would it work when I already have thousands of accounts in place?

2.  It took awhile to train people to login using DOMAIN\Username.  If they use that same syntax with these mods, will it still work properly with or without the DOMAIN\ part?  Or will it create a second account?

3.  What will happen if there is already two accounts with the same name?  I.e. if someone created an account called "username", then realized they had to log on as "DOMAIN\username", there are two accounts there.

 
New Post
10/26/2006 12:15 PM
 

1) I am in an intranet environment with 1000s of users.  I had to go in and update the database to remove the domain name from the username in both the Users and aspnet_Users tables.

2) No one has to log in here.  The network authenticates the users and logs them in from their credentials.  I haven't followed the path to see if this will work from a log in.  Since the AD process uses the domain name (it isn't stripped out until the getuser call takes place), I would assume they would need to continue to log in with DOMAIN\username.

3) That shouldn't be a problem.  All lookups to the username (getuser()) strip the domain from the username.  In theory, "username" and "DOMAIN\username" should both lookup "username".

 
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