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 ForumsAuthenticationAuthenticationAD on remote serverAD on remote server
Previous
 
Next
New Post
11/1/2007 11:54 AM
 

Until the source is released on dnn.com I've put it on http://dnn.gmss.org/ADProvider/tabid/314/Default.aspx

 
New Post
11/2/2007 5:46 AM
 

Thank you

 
New Post
11/12/2007 9:26 AM
 

Hi, Mike.

I extend your code. New in this version:

- AD provider work with trusted domain, it requires a properly configured settings (e.g. rootDomain, user name, password, and auth type. The auth type should be the 'Secure'). The user with these settings should has read access to AD.  It is possible to have multiply portal with diffrent AD configurations with diffrent domains.

- The User that does not authenticated with AD_Provider does not autocreated even one has ACL acces to web site. Like users with netbios domain name in LastName field.

I will be pleased to share the source with you to arrange these changes with DNN release.

VV

 
New Post
11/12/2007 10:40 AM
 

Hi Victor

If you want to .zip up your changes and sent them to me along with a detailed description of what the changes do to mhorton@telus.net I'll take a look at them.

 

 
New Post
11/19/2007 9:11 AM
 

 

New additional code give you an ability to create portals wtih diffrent AD_Provider configurations. Here is the changes...

Red – is changed or new strings.

\Providers\ADSIProvider\ADSIProvider.vb
       Public Overloads Overrides Function GetUser(ByVal LoggedOnUserName As String) As UserInfo
            Dim objAuthUser As UserInfo
            Try
                If _adsiConfig.LDAPAccesible Then
                    Dim entry As DirectoryEntry
                     entry = Utilities.GetUserEntryByName(LoggedOnUserName)
                     If Not entry Is Nothing Then
                        objAuthUser = New UserInfo
                         Dim location As String = Utilities.GetEntryLocation(entry)
                        If location.Length = 0 Then
                            location = _adsiConfig.ConfigDomainPath
                        End If
 
                        With objAuthUser
                            .PortalID = _portalSettings.PortalId
                            .GUID = entry.NativeGuid
                            .Location = location
                            .Username = LoggedOnUserName
                            .PrincipalName = Utilities.TrimUserDomainName(LoggedOnUserName) & "@" & location
                            .Username = LoggedOnUserName
                            .Membership.Password = Utilities.GetRandomPassword()
                        End With
 
                        FillUserInfo(entry, objAuthUser)
 
                    Else
                        'do not alow to login users from other domain even through these users
                        'have ACL access to resources in that domain in which web site hosts
                        'objAuthUser = GetSimplyUser(LoggedOnUserName)
                        objAuthUser = New UserInfo
                        Return objAuthUser
                    End If
 
                Else ' could not find it in AD, so populate user object with minumum info
                    objAuthUser = GetSimplyUser(LoggedOnUserName)
                End If
 
                Return objAuthUser
 
            Catch exc As System.Runtime.InteropServices.COMException
                LogException(exc)
                Return Nothing
            End Try
        End Function
\Providers\ADSIProvider\Configuration.vb
Sub New()
            Dim authConfig As DotNetNuke.Authentication.ActiveDirectory.Configuration = DotNetNuke.Authentication.ActiveDirectory.Configuration.GetConfig()
            mPortalId = authConfig.PortalId
 
            Try
                'Temporary fix this setting as TRUE for design, to be removed when release
                mConfigDomainPath = authConfig.RootDomain
                mDefaultEmailDomain = authConfig.EmailDomain
                mUserName = authConfig.UserName
                mPassword = authConfig.Password
                mAuthenticationType = CType([Enum].Parse(GetType(AuthenticationTypes), authConfig.AuthenticationType), AuthenticationTypes)
                ' IMPORTANT: Remove ADSIPath, to be added later depends on accessing method
 
                mRootDomainPath = ADSI.Utilities.ValidateDomainPath(mConfigDomainPath)
 
 
            Catch exc As Exception
                mProcessLog += exc.Message & "<br>"
            End Try
 
            ' Also check if LDAP fully accessible
 
 
            Try
                Dim ldap As New DirectoryEntry(mRootDomainPath, mUserName, mPassword, mAuthenticationType)
                'If ldap.Exists(mRootDomainPath) Then Try to find another way to check that domain exists
                mLDAPAccesible = True
                mRefCollection = New ADSI.CrossReferenceCollection(mUserName, mPassword, mAuthenticationType, mRootDomainPath)
                'End If
            Catch exc As System.Runtime.InteropServices.COMException
                mLDAPAccesible = False
                mProcessLog += exc.Message & "<br>"
                LogException(exc)
            End Try
 
            ' Also check if Authentication implemented in this Windows Network
            Dim gc As New DirectoryEntry
            Dim path As String = Utilities.GetRootDSEPath() ’Get correct path for domain other than current
            Try
                Dim rootGC As New DirectoryEntry
 
                'If rootGC.Exists("GC://" + mRootDomainPath) Then Try to find another way to check that domain exists
 
                If (mUserName.Length > 0) AndAlso (mPassword.Length > 0) Then
                    rootGC = New DirectoryEntry(path, mUserName, mPassword, mAuthenticationType)
                Else
                    rootGC = New DirectoryEntry(path)
                End If
                mConfigurationPath = CType(rootGC.Properties(ADSI_CONFIGURATIONNAMIMGCONTEXT).Value, String)
                mADSINetwork = True
                'End If
            Catch exc As System.Runtime.InteropServices.COMException
                mADSINetwork = False
                ' mLDAPAccesible = False
                mProcessLog += exc.Message & "<br>"
                LogException(exc)
                ' Nothing to do if we could not access Global Catalog, so return
 
            End Try
        End Sub
\Providers\ADSIProvider\CrossReferenceCollection.vb
Imports DotNetNuke.Common
        Public Sub New(ByVal UserName As String, ByVal Password As String, ByVal AuthType As AuthenticationTypes, Optional ByVal mRootDomain As String = "rootDSE")
            MyBase.New()
            Try
                ' Obtain NETBIOS only if LDAP accessible to prevent error
                ‘ Dim rootLDAP As New DirectoryEntry("LDAP://rootDSE", UserName, Password, AuthType)
                ‘ Dim crossRefPath As String = "LDAP://CN=Partitions," & rootLDAP.Properties("configurationNamingContext").Value.ToString
                Dim rootLDAP As New DirectoryEntry
                Dim configContext As String
                Dim crossRefPath As String
 
                mRootDomain = Utilities.GetRootDSEPath()
               
                rootLDAP = New DirectoryEntry(mRootDomain, UserName, Password, AuthType)
 
                Try
                    configContext = CType(rootLDAP.Properties("configurationNamingContext").Value, String)
 
                    crossRefPath = Utilities.GetGlobalCatalogPath() & "CN=Partitions," & configContext
                Catch ex As System.Runtime.InteropServices.COMException
                    mProcessLog += ex.Message & "<br>"
                End Try
 
                Dim objCrossRefContainer As DirectoryEntry
 
                If (UserName.Length > 0) AndAlso (Password.Length > 0) Then
                    objCrossRefContainer = New DirectoryEntry(crossRefPath, UserName, Password, AuthType)
                Else
                    objCrossRefContainer = New DirectoryEntry(crossRefPath)
               End If
 
                Dim objCrossRef As DirectoryEntry
                For Each objCrossRef In objCrossRefContainer.Children
                    If Not objCrossRef.Properties("nETBIOSName").Value Is Nothing Then
                        Dim netBIOSName As String = CType(objCrossRef.Properties("nETBIOSName").Value, String)
                        Dim canonicalName As String = CType(objCrossRef.Properties("dnsRoot").Value, String)
                        Dim domainPath As String = CType(objCrossRef.Properties("nCName").Value, String)
                        Dim crossRef As CrossReference = New CrossReference(domainPath, netBIOSName, canonicalName)
                        Me.Add(crossRef)
                    End If
                Next
            Catch ex As System.Runtime.InteropServices.COMException
                mProcessLog += ex.Message & "<br>"
            End Try
        End Sub
\Providers\ADSIProvider\Utilities.vb
New Function GetGlobalCatalogPath()
Create global catalog root entry from root domain string for ADSI operations.
New syntax for root entry to get connected is LDAP://domain_controller_address/DC=sub_domain,DC=domain,DC=ru
Public Shared Function GetGlobalCatalogPath() As String
            Dim adsiConfig As DotNetNuke.Authentication.ActiveDirectory.Configuration = DotNetNuke.Authentication.ActiveDirectory.Configuration.GetConfig()
            Dim Path As String = adsiConfig.RootDomain
 
            If Path.Length = 0 Then
                Return Path
            End If
            Path = Right(Path, Path.Length - Path.IndexOf("DC="))
            Path = Utilities.ConvertToCanonical(Path, False)
            If Path.Length > 0 Then
                Path = Path & "/"
            End If
            Path = "LDAP://" & Path
            Return Path
 End Function
New Function GetRootDSEPath()
Public Shared Function GetRootDSEPath() As String
            Return GetGlobalCatalogPath() & "RootDSE"
End Function
Modified Function
Public Shared Function GetRootForestPath(Optional ByVal ADSIPath As ADSI.Path = ADSI.Path.GC) As String
            Try
                Dim authConfig As DotNetNuke.Authentication.ActiveDirectory.Configuration = DotNetNuke.Authentication.ActiveDirectory.Configuration.GetConfig()
                Dim strADSIPath As String = ADSIPath.ToString & "://"
                ' convert ADSI string to "GC://global_catalog_for_domain_com/RootDSE" for access to trusted domains
                Dim rootDomainName = ConvertToCanonical(authConfig.RootDomain, False)
                Dim authType As AuthenticationTypes = CType([Enum].Parse(GetType(AuthenticationTypes), authConfig.AuthenticationType), AuthenticationTypes)
                If rootDomainName.Length > 0 Then
                    rootDomainName = rootDomainName & "/"
                End If
 
                Dim ADsRoot As New DirectoryEntry(strADSIPath & rootDomainName & "rootDSE", authConfig.UserName, authConfig.Password, authType)
                Dim strRootDomain As String = strADSIPath & rootDomainName & CType(ADsRoot.Properties(Configuration.ADSI_ROOTDOMAINNAMIMGCONTEXT).Value, String)
 
                Return strRootDomain
            Catch ex As System.Runtime.InteropServices.COMException
                LogException(ex)
                Return Nothing
            End Try
        End Function
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsAuthenticationAuthenticationAD on remote serverAD on remote server


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