Help -- Authenticating user against LDAP using ASP

Discussion in 'ASP General' started by DejaUser, Dec 23, 2004.

  1. DejaUser

    DejaUser Guest

    I have been strugling with this one for few weeks now. I hope to get
    some help here.

    Following code works fine, except that I have to hard-code the user's
    fullpath (2nd parameter of the OpenDSObject() method).

    Here is the code:

    --------------------------

    sub login5(uid, password)

    Dim userName, ldapserver, dso, lobjUser, ldap_path

    ldap_path = "LDAP://servername/dc=domain,dc=com"
    userName =
    "uid=#userid#,ou=int7,ou=internal,ou=people,c=us,cn=users,dc=domain,dc=com"
    userName = Replace(userName, "#userid#", uid)

    ' Connect to the LDAP Directory
    Set dso = GetObject("LDAP:")

    'Validate the User Name and Password
    Set lobjUser = dso_OpenDSObject(ldap_path, userName, password, 0)


    If Err.number <> 0 Then
    Response.Write "AUTHENTICATION FAILURE!"
    Set lobjUser = nothing
    Set dso = nothing
    Else
    Response.Write "SUCCESS!"
    end if
    end sub

    -------------------------

    For this this work, I need to know exact path of the user

    i.e. userName =
    "uid=#userid#,ou=int7,ou=internal,ou=people,c=us,cn=users,dc=domain,dc=com"

    Is there anyway to do something like this or is there a better
    approach? I just want to pass in a userid and password and let it
    search the whole directory for the given uid to authenticate.

    userName = "uid=#userid#,ou=*,ou=*,ou=*,c=*,cn=*,dc=domain,dc=com"
    Thanks
    DejaUser, Dec 23, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mrwoopey
    Replies:
    3
    Views:
    9,541
    mrwoopey
    Jun 30, 2003
  2. Jr. BTS dev!
    Replies:
    2
    Views:
    1,622
    =?Utf-8?B?Q2hhc2U=?=
    Jan 27, 2006
  3. Eddy C
    Replies:
    1
    Views:
    411
    Abhijat Vatsyayan
    Jan 9, 2006
  4. bugnthecode
    Replies:
    5
    Views:
    3,960
    Brandon McCombs
    Feb 8, 2007
  5. Paul East
    Replies:
    3
    Views:
    291
    Beginner
    Mar 2, 2004
Loading...

Share This Page