Authentication against active directory

From: Jon Delano (jd31068_at_hotmail.com)
Date: 07/22/04

  • Next message: Jim Cheshire [MSFT]: "RE: HTTP Error 401: Unauthorized"
    Date: Thu, 22 Jul 2004 20:49:47 GMT
    
    

    Hello

    I am developing a ASP.NET site (using VB).
    I found some code that allows me to authenticate the user trying to access
    the site against the active directory server for the company.

    What is happening is some users authenticate and others do not ... but they
    are all a part of the domain.
    The web server the site is running on is part of the domain (else no user
    would authenticate)

    Here is the code I use to authenticate the users :

            ' use the OLEDB provider to access the ADS Object, this allows for
    simple SQL Query for the user.
            Dim cn As New OleDb.OleDbConnection("provider=ADsDSOObject;User ID="
    & txtUserName.Text & ";Password=" & txtPassword.Text)
            Dim cmd As New OleDb.OleDbCommand("Select GivenName, sn from
    'LDAP://[domain is here]' where samAccountName='" & txtUserName.Text & "'",
    cn)
            Dim dtrdr As OleDb.OleDbDataReader

            Try
                cn.Open()

                dtrdr = cmd.ExecuteReader
                If dtrdr.Read = True Then
                    ' user authenticated against active directory
                    Session.Add("UserFirstName", dtrdr("GivenName"))
                    Session.Add("UserLastName", dtrdr("sn"))
                    UserIsPhysician()

                    If Session("PhysicianID") = -1 Then Exit Sub

                    Server.Transfer("patientlist.aspx")
                Else
                    Label1.Text = "Unable to access user data."
                End If
                dtrdr.Close()

            Catch ex As Exception
                Dim exMsg As String
                If InStr(ex.Message, "PERMISSION") > 0 Then
                    exMsg = ""
                Else
                    exMsg = ex.Message
                End If
                Label1.Text = "Invalid Username or Password. " & exMsg
            End Try

            cmd = Nothing
            dtrdr = Nothing
            cn.Close()
            cn = Nothing

    I can't understand why some users will work fine and others just won't.

    If anyone can offer any ideas ... it would be greatly appreicated.

    Thank you
    Jon


  • Next message: Jim Cheshire [MSFT]: "RE: HTTP Error 401: Unauthorized"

    Relevant Pages

    • Re: Slow LDAP Queries
      ... > I am using ldap_bind to connect to an Active Directory server to ... > authenticate users on a website. ... > occasionally, and at random, the process to authenticate the user will ... This will possibly eliminate PHP as the culprit. ...
      (php.general)
    • AD thru Proxy 2.0
      ... We need to connect to an Active Directory server to ... authenticate to an AD Domain thru proxy 2.0 on a windows ...
      (microsoft.public.win2000.active_directory)
    • Delegation in ASP.NET
      ... As the title suggests I have a question about delegation in ASP.NET. ... We have an ASP.NET application running on a web server which requires ... clients to authenticate via Windows Integrated authentication. ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Delegation in ASP.NET
      ... As the title suggests I have a question about delegation in ASP.NET. ... We have an ASP.NET application running on a web server which requires ... clients to authenticate via Windows Integrated authentication. ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Re: ADSI Problem
      ... Why not just let IIS authenticate the users? ... risks by joining the web server to the domain? ... Dim strUserName ...
      (microsoft.public.windows.server.active_directory)