Commit 98b801f3 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Added more error cases.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5607 b35dd754-fafc-0310-a699-88a17e54d16e
parent afcda2e3
<%@ page import="org.jivesoftware.wildfire.ldap.LdapManager" %>
<%@ page import="javax.naming.AuthenticationException" %>
<%@ page import="javax.naming.CommunicationException" %>
<%@ page import="javax.naming.InvalidNameException" %>
<%@ page import="javax.naming.NamingException" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.Map, java.net.UnknownHostException, javax.naming.ldap.LdapContext, javax.naming.*" %>
<%
boolean success = false;
String errorDetail = "";
Map<String, String> settings = (Map<String, String>) session.getAttribute("ldapSettings");
if (settings != null) {
LdapManager manager = new LdapManager(settings);
LdapContext context = null;
try {
manager.getContext();
context = manager.getContext();
NamingEnumeration list = context.list("");
list.close();
// We were able to successfully connect to the LDAP server
success = true;
}
catch (NamingException e) {
if (e instanceof AuthenticationException) {
errorDetail = "Error authenticating with the LDAP server. Check supplied credentials";
errorDetail =
"Error authenticating with the LDAP server. Check supplied credentials.";
}
else if (e instanceof CommunicationException) {
errorDetail = "Error connecting to the LDAP server";
errorDetail = "Error connecting to the LDAP server. Ensure that the directory " +
"server is running at the specified host name and port and that a firewall " +
"is not blocking access to the server.";
Throwable cause = e.getCause();
if (cause != null) {
if (cause instanceof UnknownHostException) {
errorDetail = "Unknown host address.";
}
}
}
else if (e instanceof InvalidNameException) {
errorDetail = "Invalid DN syntax or Naming violation";
errorDetail = "Invalid DN syntax or naming violation.";
}
else if (e instanceof NameNotFoundException) {
errorDetail = "Error verifying base DN. Verify that the value is correct.";
}
else {
errorDetail = e.getExplanation();
}
e.printStackTrace();
}
finally {
if (context != null) {
try {
context.close();
}
catch (Exception e) {
}
}
}
}
%>
<!-- BEGIN connection settings test panel -->
......@@ -49,7 +69,7 @@
Close this test panel and continue to the next step.</p>
<% } else { %>
<h4 class="jive-testError">Status: Error</h4>
<p><%= errorDetail %>.</p>
<p><%= errorDetail %></p>
<% } %>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment