<%@ page import="javax.naming.*, javax.naming.directory.*, java.util.*, javax.servlet.*" %> <%@ page import="javax.servlet.http.*,javax.naming.ldap.*, com.sun.jndi.ldap.ctl.*" %> <%@ page import="uo.antiharvest.*, uo.db.connection.*" %> <%@ page import="uo.naming.ldap.OnlineDirectoryHelper, uo.naming.ldap.results.format.FormattedResultEntry"%> <%@ page import="uo.naming.ldap.*, uo.naming.ldap.results.format.*"%> <%@ page session="false" %> <%@ page errorPage="directory_error.jsp" %> <% /* * Purpose: Provide LDAP searching capabilities for the UO online directory. * * Dependencies: * Sun JNDI/LDAP Booster Pack 1.0 (ldapbp.jar) * * Modification History * Date: Who: Comment: * -------- ---------- -------------------------------------------- * cort Initial creation. * 02/26/04 derek Modified to sort results using ldap control. * 04/06/04 cort Changed settings to "test" * 05/20/04 derek Modified to search for departments in LDAP. * Changed staff/student output to accomodate * changes necessary for department search. * 01/07/05 keith Exempted all of 128.223 from anti-harvest. * */ String ip = request.getRemoteAddr(); // Gather AntiHarvest data for this IP address. DirectoryAntiHarvest ah = new DirectoryAntiHarvest(); ah.setAhConfig("default"); ah.setupDbConnection("default"); /* Uncomment Derek */ // Default harvest state is "not a harvester" int isAHarvester = 0; // 1/7/05 Keith -- Changed to allow all of uoregon.edu without anti-harvesting. if (!(ip.substring(0,7).compareTo("128.223") == 0)) { isAHarvester = ah.checkISHarvester(ip); } ah.closeDbConnection(); String errorString = ""; %> University of Oregon -- Directory Search
<% OnlineDirectoryHelper odh = new OnlineDirectoryHelper(); String searchMethod = null; String searchDomain = null; String searchBy = null; try { odh.setParameters(request); searchMethod = odh.getSearchMethod(); searchDomain = odh.getSearchDomain(); searchBy = odh.getSearchBy(); if (searchMethod != null && searchMethod.equals("staff")) { out.println(""); } else if (searchMethod != null && searchMethod.equals("student")) { out.println(""); } else if (searchMethod != null && (searchMethod.equals("dept") || searchMethod.equals("deptOu"))) { out.println(""); } %> <% } catch(IllegalArgumentException iae) { errorString = iae.getMessage(); } if (isAHarvester == 1) { out.println(""); errorString = "Search results have been suppressed due to excessive use."; } /* Check to see if any errors have occured */ else if(errorString != null && errorString.length() > 1 ) { out.println(""); } else { int numResults = 0; // Display person query results if("person".equals(searchDomain)) { ArrayList resultList = odh.getFormattedSearchResults(); //System.out.println(resultList); //System.out.println("Size: "+resultList.size()); FormattedResultEntry fre = new FormattedResultEntry(); numResults = resultList.size(); out.println(""); for (int i = 0; i < numResults; i++) { ArrayList al = (ArrayList) resultList.get(i); for (int j=0;j"); out.println(""); out.println(""); } out.println(""); out.println(""); out.println(""); } if(numResults == 20) { out.println(""); out.println(""); } } // Display departmental query results else if("dept".equals(searchDomain) && "desc".equals(searchBy)) { ArrayList resultList = odh.getSearchResults().getResults().getEntities(); numResults = resultList.size(); if(numResults > 0) { %> <% } LdapAttribute att; LdapAttribute ouAtt; String ou; for (int i = 0; i < numResults; i++) { LdapEntity entity = (LdapEntity) resultList.get(i); Map attributes = entity.getAttributes(); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); } if(numResults == 20) { out.println(""); out.println(""); } } // Display departmental drill down results else if("dept".equals(searchDomain) && "ou".equals(searchBy)) { ArrayList resultList = odh.getSearchResults().getResults().getEntities(); numResults = resultList.size(); LdapAttribute att = null; LdapAttribute uriAtt = null; String uriValue; for (int i = 0; i < numResults; i++) { att = null; uriAtt = null; if(i == 0) { /* Display first entry in form format */ LdapEntity entity = (LdapEntity) resultList.get(i); Map attributes = entity.getAttributes(); att = (LdapAttribute) attributes.get("description"); out.println(""); out.println(""); out.println(""); out.println(""); att = (LdapAttribute) attributes.get("telephoneNumber"); out.println(""); out.println(""); out.println(""); att = (LdapAttribute) attributes.get("facsimileTelephoneNumber"); out.println(""); out.println(""); out.println(""); att = (LdapAttribute) attributes.get("physicalDeliveryOfficeName"); out.println(""); out.println(""); out.println(""); out.println(""); } else { /* Display other entries in list format */ LdapEntity entity = (LdapEntity) resultList.get(i); String match = odh.getBindName().equals(entity.getBindName()) ? "" : ""; String endMatch = odh.getBindName().equals(entity.getBindName()) ? "" : ""; Map attributes = entity.getAttributes(); out.println(""); out.println(""+endMatch); out.println(""+endMatch); out.println(""); } } } if(numResults == 0) { out.println(""); out.println(""); } out.println(""); } %>
Return to UO Directory University of Oregon - Return to Home Page
Header bar

Faculty/Staff

Students

Departments

<% if(!"ou".equals(searchBy)) { if(odh.getSearchString().length() > 50) { out.println("You entered: " + odh.getSearchString().substring(1,50) + "... "); } else { out.println("You entered: " + odh.getSearchString()); } } %>

Search results have been suppressed due to excessive use.


"+errorString+"


"); out.println(fre.getName()+": "); out.println(""); out.println(fre.getValue()); out.println("
"); out.println("
"); out.println("

There are more entries that match your search criteria. To find others, try a more selective search.

Phone Description Location
"); att = (LdapAttribute) attributes.get("telephoneNumber"); out.println(att == null ? "" : FormattedResultUtil.formatTelephoneNumber(att.getAttributeValue())); out.println(""); att = (LdapAttribute) attributes.get("description"); ouAtt = (LdapAttribute) attributes.get("ou"); if(ouAtt == null) { out.println(att == null ? "" : att.getAttributeValue()); } else { ou = ouAtt.getAttributeValue(); out.println(att == null ? "" : ""+att.getAttributeValue()+""); } out.println(""); att = (LdapAttribute) attributes.get("physicalDeliveryOfficeName"); out.println(att == null ? "" : att.getAttributeValue()); out.println("
"); out.println("

There are more entries that match your search criteria. To find others, try a more selective search.

"); out.println(att == null ? "" : att.getDisplayTitle()+":    "); out.println(""); uriAtt = (LdapAttribute) attributes.get("labeledUri"); if(uriAtt == null) { out.println(att == null ? "" : att.getAttributeValue()); } else { uriValue = uriAtt.getAttributeValue(); if(uriValue == null || uriValue.length() == 0) { out.println(att == null ? "" : att.getAttributeValue()); } else { out.println(att == null ? "" : ""+att.getAttributeValue()+""); } } out.println("
"); out.println(att == null ? "" : att.getDisplayTitle()+":    "); out.println(""); out.println(att == null ? "" : FormattedResultUtil.formatTelephoneNumber(att.getAttributeValue())); out.println("
"); out.println(att == null ? "" : att.getDisplayTitle()+":    "); out.println(""); out.println(att == null ? "" : FormattedResultUtil.formatTelephoneNumber(att.getAttributeValue())); out.println("
"); out.println(att == null ? "" : att.getDisplayTitle()+":    "); out.println(""); out.println(att == null ? "" : FormattedResultUtil.formatHTMLAddress(att.getAttributeValue())); out.println("

 "+match); att = (LdapAttribute) attributes.get("telephoneNumber"); out.println(att == null ? "" : FormattedResultUtil.formatTelephoneNumber(att.getAttributeValue())); out.println(""+match); att = (LdapAttribute) attributes.get("description"); uriAtt = (LdapAttribute) attributes.get("labeledUri"); if(uriAtt == null) { out.println(att == null ? "" : att.getAttributeValue()); } else { uriValue = uriAtt.getAttributeValue(); out.println(att == null ? "" : ""+att.getAttributeValue()+""); } out.println("

We're sorry, but your search returned no results.
Please try again.


Back to Search

Telecommunications Services - (541) 346-1017
5225 University of Oregon, Eugene OR 97403-5225
Send questions or feedback to directory@oregon.uoregon.edu
UO Home Page