Hi,
I am very new to the legacy Classic ASP and trying to set up an intermediate authentication page for a classic asp application using vbScript.I need to check for LDAP authentication and on its success to verify the availability of the user in a local DB to verify the signup for the tool. Here is the code below (referred from various websites around the internet) not working for me and throwing Http 500 Internal Server error. Since I am not sure how to debug and what error it really is,I am stuck with no ideas.Am I missing anything?? The application is hosted in IIS 7.5 with default app pool on Integrated mode.
It would be good, if some one give me some insight on this
What I have tried:
<html>
<head></head>
<body>
<%
on error resume next
dim strUser,strQuery,oConn,cmd,oRS,AuthenticateUser,strPwd
strUser= Replace(Trim(Request("userid")),"'","`")
strPwd= Request("upassword")
strservername = "mydomain.com:389"
AuthenticateUser = false
strQuery = "SELECT cn FROM 'LDAP://" & strservername & "' WHERE objectClass='user'"
set oConn = server.CreateObject("ADODB.Connection")
oConn.Provider = "ADsDSOOBJECT"
oConn.Properties("User ID") = strUser
oConn.Properties("Password")= strPwd
oConn.Properties("Encrypt Password") = true
oConn.open "ADs Provider", strUser,strPwd
set cmd = server.CreateObject("ADODB.Command")
set cmd.ActiveConnection = oConn
cmd.CommandText = strQuery
set oRS = cmd.Execute
If Err.number <> 0 then
Response.Redirect "index.asp?errvar=" &Err.number & Err.description
'Response.Write Err.description &"
"
'Response.End
End If
if oRS.bof or oRS.eof then
AuthenticateUser = false
else
AuthenticateUser = true
end if
set oRS = nothing
set oConn = nothing
'CHK THE DATABASE FOR THE USER Availability
If AuthenticateUser = true
on error resume next
dim sql, Rs1
sql="Query to check the user available in the tool DB"
Set Rs1 = ObjConn.Execute(sql)
If Err.number <> 0 then
Response.Write "ERROR OCCURED" &"
"
Response.Write Err.description &"
"
Response.End
End If
If Not Rs1.EOF Then
UserID=Trim(Rs1("UserID"))
End If
Rs1.Close
Set Rs1 = Nothing
If UCase(UserID) = UCase(Request("UserID")) Then
Session("UserId") = UserId
%>
<form action="" method="POST" name="form1">
<input type="hidden" name="userid" value="<%=UserID%>">
</form>
<script>
document.form1.action="Home.asp";
document.form1.submit()
</script>
<%End If%>
<%Else%>
<form action="" method="POST" name="form1">
<input type="hidden" name="Flag" value="1">
</form>
<script>
document.form1.action="index.asp";
document.form1.submit()
</script>
<%End If%>
</body>
</html>