<%@ page import="java.util.*" %>
<%@ page import="com.novell.ldap.*" %>
<%@ page import="com.novell.ldap.util.*" %>
<%@include file="config.java"%>
<%@ page errorPage="error.jsp" %>
<HTML>
<HEAD>
<SCRIPT language="javascript">
function checkForm(form)
{
if ((form.name.value == null) || (form.name.value.length == 0))
{
alert("You must specify a name!");
return false;
}
if ((form.password.value == null) || (form.password.value.length == 0))
{
alert("You must specify a password!");
return false;
}
return true;
}
</SCRIPT>
<TITLE>LDAP User Consistency Checker</TITLE>
<link rel="stylesheet" href="hf_style.css">
</HEAD>
<BODY leftmargin="0" marginwidth="0" topmargin="0" marginheight="0">
<%
// Get the current connection object
LDAPConnection connection = (LDAPConnection)session.getValue("Connection");
// If no connection is available bind anonymously
if (connection == null) {
// create a connection to the host on the specified port
try {
connection = new LDAPConnection();
connection.connect(Address, connection.DEFAULT_PORT);
}
catch (LDAPException e){
String message = e.getMessage();
throw new Exception("Application could not establish a connection to the tree, please ensure your configuration is correct " + message);
}
// Save connection object in session
session.putValue("Connection", connection);
}
// Clear any leftover session vars
if (session.getValue("who") != null)
{
session.removeValue("who");
}
if (session.getValue("pass") != null)
{
session.removeValue("pass");
}
%>
<table border="0" cellpadding="0" cellspacing="0">
<tr height="90">
<td height="90" colspan="3">
<img src="images/logo.png" border="0"></td>
</tr>
<tr>
<td bgcolor="#A5BFFF" valign="top" width="211">
<p>
<%
String userdn = connection.getAuthenticationDN();
boolean auth;
// Authenticated?
// The Java LDAP Draft 16 was updated to clarify that getAuthenticationDN
// should return null if the connection is anonymous
// as of Oct 2001, Novell JLDAP SDK is returning an empty string
if ( (userdn != "") && (userdn != null) ) {
auth = true;
// save off the DN of the user
session.putValue("userdn", userdn);
// get the CN of the user
String name = (String) session.getValue("name");
session.putValue("name", name);
%>
<div class="marginleft1">
<br>Welcome<br><SPAN CLASS="head2e"><%=name%></span><br>
<br>
<br>
<a href="unauth.jsp">Logout</a><br>
<br>
</div>
<td valign="top" width="15"></td>
<td valign="top" width="537">
<div class="head2">User Compare<br></div>
<form name="usercomp" action="examineother.jsp" method="post" >"return checkFrom(this1)">
<table border="o" cellpadding="2" cellspacing="0" bgcolor="white">
<tr>
<td class="head4">Name:</td>
<td colspan="2" valign="top" class="mediumtext">
<input type="text" size="15" name="who" value="">
</td>
</tr>
<tr>
<td valign="top" colspan="3">
<input type="submit" name="Submit" value="Search"></td></tr>
</table>
</form>
</div>
<div class="head2">Authenticate Test<br></div>
<form name="passcomp" action="passwordother.jsp" method="post" >"return checkFrom(this1)">
<table border="o" cellpadding="2" cellspacing="0" bgcolor="white">
<tr>
<td class="head4">Name:</td>
<td colspan="2" valign="top" class="mediumtext">
<input type="text" size="15" name="who" value="">
</td>
</tr>
<tr>
<td class="head4">Password:</td>
<td colspan="2" valign="top" class="mediumtext">
<input type="text" size="15" name="pass" value="">
</td>
</tr>
<tr>
<td valign="top" colspan="3">
<input type="submit" name="Submit" value="Authenticate"></td></tr>
</table>
</form>
</div>
<%
} else {
auth = false;
%>
<div class="marginleft1">
<span class="head2e">Please Login</span><br>
<br></p>
<form name="AuthUser" action="auth.jsp" method="post" >"return checkForm(this)">
<table border="0" cellpadding="2" cellspacing="0" bgcolor="white" width="170">
<tr><td valign="top" colspan="3" class="head3">Login</td></tr>
<tr height="15"><td class="head4" colspan="3" height="15"></td></tr>
<tr><td class="head4">Name:</td>
<td class="head4" colspan="2" valign="top" class="mediumtext"><input type="text" size="15" name="name" value=""></td></tr>
<tr><td valign="top" class="head4">Password:</td>
<td class="head4" valign="top" colspan="2"><input type="password"
size="15" name="password" value=""></td></tr>
<tr height="15"><td class="head4" valign="top" colspan="3" height="15"></td></tr>
<tr><td class="head4" valign="top" colspan="3">
<input type="submit" name="Submit" value="Login"></td></tr>
</table></form></div>
<%
}
%>
<p></p></td><td valign="top" width="15"></td></tr></table><p>
<%
if (debug)
{
Enumeration keys = session.getAttributeNames();
while (keys.hasMoreElements())
{
String key = (String)keys.nextElement();
out.println(key + ": " + session.getValue(key) + "<br>");
}
}
%>
</p>
</BODY>
</HTML>