Hi I'm trying to do an ASP authentication using Ldap and would like to have the users directed to pages based on the Organizational Unit. My ASP knowledge is pretty basic but would really like to get this sorted to complete the intranet.
Thx I've found the following code on this website and manage to get the username and password authentication working just need to figure out how to redirect to the OU.
Thanks
Thx I've found the following code on this website and manage to get the username and password authentication working just need to figure out how to redirect to the OU.
Thanks
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Intranet</title> </head> <body> <% dim submit dim UserName dim Password UserName = "mydoamin/username" Password = "" Domain = "mydomain" submit = request.form("submit") if submit = "Authenticate" then UserName = request.form("UserName") Password = request.form("Password") Domain = request.form("Domain") result = AuthenticateUser(UserName, Password, Domain) if result then Response.Redirect("basic page") else response.write "<h3>Authentication Failed!</h3>" end if end if response.write "<hr><form method=post>" response.write "<table>" response.write "<tr>" response.write "<td><b>Username: </b></td><td><input type=""text"" name=""UserName"" value=""" & UserName & """>" response.write "</tr>" response.write "<tr>" response.write "<td><b>Password: </b></td><td><input type=""password"" name=""Password"" value=""" & Password & """ </td>" response.write "</tr>" response.write "<tr>" response.write "<td><b>AD Domain: </b></td><td><input type=""text"" name=""Domain"" value=""" & Domain & """ <br></td>" response.write "</tr>" response.write "<tr>" response.write "<td> </td><td><input name=""submit"" type=""submit"" value=""Authenticate""></td>" response.write "</tr>" response.write "</table>" response.write "</form>" response.end function AuthenticateUser(UserName, Password, Domain) dim strUser ' assume failure AuthenticateUser = false strUser = UserName strPassword = Password strQuery = "SELECT cn FROM 'LDAP://" & Domain & "' WHERE objectClass='*' " set oConn = server.CreateObject("ADODB.Connection") oConn.Provider = "ADsDSOOBJECT" oConn.Properties("User ID") = strUser oConn.Properties("Password") = strPassword oConn.Properties("Encrypt Password") = true oConn.open "DS Query", strUser, strPassword set cmd = server.CreateObject("ADODB.Command") set cmd.ActiveConnection = oConn cmd.CommandText = strQuery on error resume next set oRS = cmd.Execute if oRS.bof or oRS.eof then AuthenticateUser = false else AuthenticateUser = true end if set oRS = nothing set oConn = nothing end function %> </body> </html>
Comment