pppebble88
11-05-2009, 03:56 PM
Hello,
We just got word that we have to use only PERL on the project we are working on. Currently, we have it pretty much working with ASP. I was wondering if someone could help us convert the code from asp to perl. Thanks a lot and the code is below.
<%
'Look for logoff request
StatusIn = request.querystring("Status")
If StatusIn = "Logoff" Then
Session.abandon
msg = "User Logged Off."
End If
SessName = Session("Name")
If SessName <> "" then
response.redirect("staff.html")
End If
strServerName = ""
strName = Request("username")
strPassword = Request("password")
ActionIN = request("Action")
If ActionIn = "Logon" then
If strName = "" OR strPassword = "" then
msg = "You must include both a User Name and a Password."
End If
If strName <> "" AND strPassword <> "" then
'Establish an object connection and set up the query to find the DN
set oConn = CreateObject("ADODB.Connection")
set oCommand = CreateObject("ADODB.Command")
set oRS = CreateObject("ADODB.Recordset")
oConn.Provider = "ADsDSOObject"
oConn.Open "Ads Provider"
set oCommand.ActiveConnection = oConn 'set the active connection
strQuery= "<LDAP://" & strServername & ">;(&(cn=" & strName & "*));Adspath,cn;subtree"
oCommand.CommandText = strQuery
set oRS = oCommand.Execute 'Execute the query
'Dissect the object to find the DN (Adspath)
Do While Not oRS.EOF
mydn = oRS.Fields(0)
ReturnValue2 = oRS.Fields(0)
Exit Do
oRS.MoveNext
Loop
'Dissect the variable to get the string we want
querydn = InStrRev(mydn, "/")
querydn = Mid(mydn, querydn + 1)
'Now that we have our DN we requery to check for authentication
On Error Resume Next
strDSN = ""
Set dso = GetObject("LDAP:")
Set comp = dso.OpenDSObject(strDSN,querydn,strPassword,0)
If Err.Number = 0 Then
'Check to see if the user is in the ACL in the database%>
<!--#include file="dbconn.asp"-->
<% SQL_query = "SELECT * FROM hbusers where User = '" & strName & "'"
Set RS = MyConn.Execute(SQL_query)
If not rs.eof then
'Get User Role
RoleIn = RS("Role")
'create session variables.
Session("Name") = strName
Session("Role") = RoleIn
response.redirect "http://www.google.com"
End If
If rs.eof then
msg = "You are not authorized to access this application."
End If
ElseIf Err.Number <> 0 Then
msg = "You have entered the incorrect Novell password. Please go back and enter the correct password."
End If
End If
End If
%>
We just got word that we have to use only PERL on the project we are working on. Currently, we have it pretty much working with ASP. I was wondering if someone could help us convert the code from asp to perl. Thanks a lot and the code is below.
<%
'Look for logoff request
StatusIn = request.querystring("Status")
If StatusIn = "Logoff" Then
Session.abandon
msg = "User Logged Off."
End If
SessName = Session("Name")
If SessName <> "" then
response.redirect("staff.html")
End If
strServerName = ""
strName = Request("username")
strPassword = Request("password")
ActionIN = request("Action")
If ActionIn = "Logon" then
If strName = "" OR strPassword = "" then
msg = "You must include both a User Name and a Password."
End If
If strName <> "" AND strPassword <> "" then
'Establish an object connection and set up the query to find the DN
set oConn = CreateObject("ADODB.Connection")
set oCommand = CreateObject("ADODB.Command")
set oRS = CreateObject("ADODB.Recordset")
oConn.Provider = "ADsDSOObject"
oConn.Open "Ads Provider"
set oCommand.ActiveConnection = oConn 'set the active connection
strQuery= "<LDAP://" & strServername & ">;(&(cn=" & strName & "*));Adspath,cn;subtree"
oCommand.CommandText = strQuery
set oRS = oCommand.Execute 'Execute the query
'Dissect the object to find the DN (Adspath)
Do While Not oRS.EOF
mydn = oRS.Fields(0)
ReturnValue2 = oRS.Fields(0)
Exit Do
oRS.MoveNext
Loop
'Dissect the variable to get the string we want
querydn = InStrRev(mydn, "/")
querydn = Mid(mydn, querydn + 1)
'Now that we have our DN we requery to check for authentication
On Error Resume Next
strDSN = ""
Set dso = GetObject("LDAP:")
Set comp = dso.OpenDSObject(strDSN,querydn,strPassword,0)
If Err.Number = 0 Then
'Check to see if the user is in the ACL in the database%>
<!--#include file="dbconn.asp"-->
<% SQL_query = "SELECT * FROM hbusers where User = '" & strName & "'"
Set RS = MyConn.Execute(SQL_query)
If not rs.eof then
'Get User Role
RoleIn = RS("Role")
'create session variables.
Session("Name") = strName
Session("Role") = RoleIn
response.redirect "http://www.google.com"
End If
If rs.eof then
msg = "You are not authorized to access this application."
End If
ElseIf Err.Number <> 0 Then
msg = "You have entered the incorrect Novell password. Please go back and enter the correct password."
End If
End If
End If
%>