asked on
<%
username = request.form("username")
password = request.form("password")
Mode = 0
Set condb = Server.CreateObject("ADODB.connection")
condb.Provider = "ADsDSOObject"
condb.Open "Active Directory Provider"
Set rslog = Server.CreateObject("ADODB.Recordset")
rsselect = "SELECT sAMAccountName, Memberof, displayname FROM 'LDAP://OU=SBSUsers,OU=Users,OU=MyBusiness,DC=learn,DC=local' WHERE sAMAccountName = '" & username & "'"
rslog.Open rsselect, condb
If not rslog.eof then
ADMember = rslog("memberOf")
DisplayName = rslog("DisplayName")
If Not IsNull(ADMember) Then
ADString = CStr(ADMember(LBound(ADMember)))
For ADVariable = LBound(ADMember)+1 To UBound(ADMember)
ADString = ADString & "," & CStr(ADMember(ADVariable))
Next
End if
If InStr(ADString, "learn event editors") <> 0 Then
Mode = 1
End If
If InStr(ADString, "learn web editors") <> 0 Then
Mode = 2
End If
If InStr(ADString, "tgi faculty") <> 0 Then
Mode = 3
End If
Else
*redirect to undetermined error page
End if
result = AuthenticateUser(username, password)
If (result <> 1) then
*redirect to undetermined error page
End If
function AuthenticateUser(username, password)
AuthenticateUser = 0
rsselect2 = "SELECT cn FROM 'LDAP://OU=SBSUsers,OU=Users,OU=MyBusiness,DC=learn,DC=local'"
set condb2 = Server.CreateObject("ADODB.Connection")
condb2.Provider = "ADsDSOOBJECT"
condb2.Properties("User ID") = username
condb2.Properties("Password") = password
condb2.Properties("Encrypt Password") = true
condb2.open "DS Query", username, password
set cmd = server.CreateObject("ADODB.Command")
set cmd.ActiveConnection = condb2
cmd.CommandText = rsselect2
on error resume next
set rslog2 = cmd.Execute
if (rslog2.bof or rslog2.eof) then
AuthenticateUser = 0
else
AuthenticateUser = 1
end if
set rslog2 = nothing
set condb2 = nothing
end function
validkey = now()
Response.Cookies("user").Expires = Date + 1
Response.Cookies("user").Domain = "dev.learn.edu"
Response.Cookies("user")("Mode") = mode
Response.Cookies("user")("DisplayName") = DisplayName
*redirect to undetermined login success page
%>