Authentication against AD on windows 2003 using ASP

Discussion in 'Programming' started by ASP_CODE, Oct 9, 2007.

  1. #1
    Hi all,

    I used to have the following ASP code (below) that runs on windows 2000 and authenticates users against the Active Directory. The code is working fine. However, after upgrading from Win2000 to Win2003 (IIS 6), authentication is failing, although the code is still working if run on win2000.

    I tried to capture packets during the authentication phase from both win2000 and win2003 and I found out that there is a slight difference between the two although I believe that this is an OS bit not ASP thing.

    Here is the ASP code for AD authentication:

    username = "\" & Request.Form("username")
    password = Request.Form("password")
    domain = "domain.pre"

    Set adoCon = Server.CreateObject("ADODB.Connection")

    adoCon.Provider = "ADsDSOOBJECT"
    adoCon.Properties("User ID") = username
    adoCon.Properties("Password") = password
    adoCon.Properties("Encrypt Password") = true
    adoCon.Open "DS Query", username, password

    strQuery = "SELECT cn FROM 'LDAP://" & domain & "' WHERE objectClass='*' "

    set cmd = Server.CreateObject("ADODB.Command")
    set cmd.ActiveConnection = adoCon
    cmd.CommandText = strQuery
    on error resume next

    set rs = cmd.Execute
    if rs.bof or rs.eof then
    Response.Redirect("main.html")
    else
    Session("logged_in")="yes"
    Session("username")=username
    Response.Redirect("user.asp")
    end if


    I would appreciate any help or support on this.

    Thanks in advance,
    A
     
    ASP_CODE, Oct 9, 2007 IP