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

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Security.vb replaced by?Security.vb replaced by?
Previous
 
Next
New Post
1/23/2007 11:53 AM
 

I am attempting to integrate Novell logins with DNN, and have stumbled across a modification made by someone. The file modified is Security.vb, but I cannot find this in DNN4. Has the file been replaced?

If so, what to? Here is a sample.

Many thanks

Drew

--- SAMPLE:--

 

 Public Function UserLogin(ByVal Username As String, ByVal Password As String, ByVal PortalID As Integer) As Integer
            ' Obtain PortalSettings from Current Context
            Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings)

            Dim intUserId As Integer = -1

            'Opening a Connection to the Database
            Dim myConnection As New SqlConnection(GetDBConnectionString)

            myConnection.Open()

            'BEGIN NOVELL LDAP CUSTOMIZATION
            '************************************************

            'Test for an LDAP Account for UserName and Password Entered

            Dim LDAPObjectQuery As New NWIDir
            Dim LDAPNwDirAuth As New NWIDirAuthenticator
            Dim LDAPFullName As String
            Dim LDAPAddress As String
            Dim LDAPResults

            'Stop

            'LDAP connection Information

            LDAPObjectQuery.FullName = "ldap://ldap.anderson.edu/o=anderson_u"
            LDAPObjectQuery.PortNumber = 389

 

            'LDAP search and Filter.
            'Searching for a username which is attached the the CN attribute

            LDAPObjectQuery.Fields = "cn, givenName"
            LDAPObjectQuery.Filter = "cn=" & Username
            LDAPObjectQuery.SearchScope = 2
            LDAPObjectQuery.SearchMode = 0

 

            'Connecting to LDAP

            LDAPObjectQuery.Connect()

            'Executing Search Query on LDAP

            LDAPResults = LDAPObjectQuery.Search

            'Determining if Username and Password exist in LDAP

            Try
                If LDAPResults.Count = 1 Then
                    LDAPFullName = LDAPResults.Item(0).FullName

                    LDAPNwDirAuth.FullName = LDAPFullName

                    'Executing Query

                    'LDAP Query connection Information

                    Dim LDAPQuery As New NWIDirQuery
                    Dim LDAPRes As NWQueryResults
                    LDAPQuery.FullName = LDAPFullName
                    LDAPQuery.PortNumber = 389
                    'LDAP Query seach and Filter
                    LDAPQuery.Fields = "sn, givenName, mail, homephone, homepostaladdress"
                    LDAPQuery.Filter = "cn=" & Username
                    LDAPQuery.SearchScope = 2
                    LDAPQuery.SearchMode = 0
                    LDAPQuery.Connect()
                    LDAPRes = LDAPQuery.Search()
                    'LDAP Query results parsing
                    'Assigning LDAP Atrribute information to variables for a user.
                    'This information will be used to insert new user into DNN database.
                    Dim oMail As Object = LDAPRes.Item(0).FieldValue("mail")
                    Dim oAdd As Object = LDAPRes.Item(0).FieldValue("homepostaladdress")
                    Dim oPhone As Object = LDAPRes.Item(0).FieldValue("homephone")
                    Dim oFname As Object = LDAPRes.Item(0).FieldValue("givenName")
                    Dim oLname As Object = LDAPRes.Item(0).FieldValue("sn")
                    Dim mail As String = oMail(0)
                    Dim phone As String = ""
                    Dim add1 As String = ""
                    Dim city As String = ""
                    Dim state As String = ""
                    Dim zip As String = ""
                    Dim country As String = ""
                    If Not oAdd.length() = 0 Then
                        add1 = oAdd(0)
                        country = "United States"
                        'oadd consist of 0 & 1
                        'eg. 0 = 1100 E. 5th Street
                        'eg. 1 = Anderson, IN 46012
                        If oAdd.length() = 2 Then
                            Dim add2 As String = oAdd(1)
                            Dim csz = add2.Split(", ")
                            city = csz(0)
                            Dim add3 As String = csz(1)
                            Dim sz = add3.Split(" ")
                            state = sz(1)
                            zip = sz(2)
                        End If
                    End If
                    If Not oPhone.length() = 0 Then
                        phone = oPhone(0)
                    End If
                    Dim fname As String = oFname(0)
                    Dim lname As String = oLname(0)


         
                    LDAPNwDirAuth.Connect()

                    'If the Username and password exist
                    'and are correct than we will start
                    'the login process

                    If LDAPNwDirAuth.ValidatePassword(Password, LDAPFullName) = True Then


                        'Start of the login process

                        'Determining if user exist in DNN database
                        ' Generate Command Object based on Method
                        Dim myCommand As SqlCommand = SqlCommandGenerator.GenerateCommand(myConnection, _
                            CType(MethodBase.GetCurrentMethod(), MethodInfo), _
                            New Object() {Username, Encrypt(_portalSettings.HostSettings("EncryptionKey"), Password), PortalID})

                        'Storing the results of our query to determine if user exists in DNN Database
                        Dim result As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)

                        'Checking to See if they do not have
                        'a DNN account.  If they do not than
                        'enter decision structure
                        If result.Read Then
                            If Not IsDBNull(result("UserId")) Then
                                'Giving intUserId the value of
                                'the user who already exist in DNN
                                intUserId = Int32.Parse(result("UserId"))

                            Else
                                'If they do not have a DNN
                                'account we need to create
                                'a DNN account and log them in
                                Dim UserId As Integer
                                Dim objUser As New UsersDB

                                'Adding USER and REGISTERED ROLE to User Table and UserRole Table
                                UserId = objUser.AddUser(PortalID, fname, lname, add1, "", city, state, zip, country, phone, mail, Username, Password, "True", UserId)
                                'UserId = objUser.AddUser(PortalID, givenName, "Bond", "TestAddress1", "TestAddress1.Street", "TestAddress1.City", "TestAddress1.Region", "TestAddress1.Postal", "TestAddress1.Country", "TestAddress1.Telephone", Username & "@anderson.edu", Username, Password, "True", UserId)
                                'Assigning intUserId the UserId of the new user created
                                intUserId = UserId
                            End If

                            'Close the connection
                            result.Close()
                        End If
                    End If
                End If


            Catch ex As Exception

            End Try
            Try
                'Closing LDAP connections
                LDAPObjectQuery.Disconnect()
                LDAPNwDirAuth.Disconnect()
                LDAPObjectQuery = Nothing
                LDAPNwDirAuth = Nothing

'END OF NOVELL LDAP CUSTOMIZATION
'*****************************************

            Catch ex As Exception
            End Try

            Return intUserId

        End Function

        Public Shared Function IsInRole(ByVal role As String) As Boolean

            ' Obtain PortalSettings from Current Context
            Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings)

            If HttpContext.Current.User.Identity.Name = _portalSettings.SuperUserId.ToString Then
                Return True
            Else
                Return HttpContext.Current.User.IsInRole(role)
            End If

        End Function

 
New Post
1/24/2007 4:28 AM
 

just do a search for the method names in the source ;)

security.vb is not portalsecurity.vb

userlogin can be found in UserController.vb


Erik van Ballegoij, Former DNN Corp. Employee and DNN Expert

DNN Blog | Twitter: @erikvb | LinkedIn: Erik van Ballegoij on LinkedIn

 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Security.vb replaced by?Security.vb replaced by?


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