<%@LANGUAGE="VBScript" %>
<%
dim sUID
dim sReadOnly
dim IsFound
dim IsPosted
dim oRst
const WFDSN = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=DOIT;Initial Catalog=ChangeManage;Data Source=DOITRPT1"
sUID = ucase(Request.Form("uid")) 'Empty string if the form has not been posted
IsPosted=False
if sUID<>"" then 'The form has just been posted
IsPosted=True
'Look up the username in the database
set oRst = Server.CreateObject("ADODB.Recordset")
oRst.ActiveConnection = WFDSN
oRst.Source = "SELECT CanChange from TeamMembers WHERE UserID='" & sUID & "'"
oRst.Open,,adOpenForwardOnly,adLockReadOnly
IsFound = False
if not (oRst.EOF or oRst.BOF) then 'User was found in the database
IsFound=True
Response.Cookies("uid")=sUID
if oRst.Fields("CanChange")=True then 'Is a power user
Response.Cookies("ReadOnly")="False"
else
Response.Cookies("ReadOnly")="True"
end if
Response.Redirect "Default.htm" 'Outa here
else
Response.Cookies("uid")=""
Response.Cookies("ReadOnly")=""
end if
set oRst = nothing
end if
%>
<html>
<head>
<meta name="VI60_defaultClientScript" content="VBScript" />
<script language="VBSCRIPT">
SUB Set_Focus
form1.uid.focus()
END SUB
</script>
<meta name="Microsoft Theme" content="blends 011, default">
</head>
<title>Change Management System</title>
<body LANGUAGE="vbscript" onload="Set_Focus">
<h1>Change Management System</h1>
<form action="login.asp" method="post" id="form1" name="form1" align="left">
<p><hr /></p>
<i>If you wish to make changes to the records
in the Change Management System,
you must log in.<br>If not, simply
<a href="default.htm">continue</a>
as a read-only, anonymous user.
</i>
</p>
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td>User Name</td>
<td>
<input name="uid" id="uid" tabindex="1">
</font></td>
</tr>
<tr>
<td>
<td>
<input type="submit" name="login" value="Login" style="WIDTH: 154px; HEIGHT: 24px" id="login" tabindex="2">
</td>
</tr>
</table>
</form>
<%
if not IsFound and IsPosted then 'The user wasn't found above
%>
<font color="red">
<i>
<div id="divErr">User Not found</div>
</i>
</font>
<h3>
<font color="red">
<i>Login Failed, Please Try Again.</i>
</font>
</h3>
<%
end if
%>
</body>
</html>