Skip to main content link. Accesskey S
  • Log In
  • Help
  • IBM Logo
  • Lotus Quickr wiki
  • All Wikis
  • All Forums
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • IBM Redbooks
Community Articles Product Documentation Learning Center IBM Redbooks This category Lotus Quickr 8.5 for WebSphere Portal Documentation Lotus Quickr 8.5.1 for Domino Documentation Lotus Quickr Connectors 8.5 Documentation Custom Search Scope...
Search
  • New Article
  • Share Show Menu▼
  • Subscribe Show Menu▼

About the Original Author

vincent vc cailly
Contribution Summary:
  • Articles authored: 2
  • Articles edited: 2
  • Comments Posted: 3

Recent articles by this author

A sample service to retrieve the user's photo from an ldap directory and to display it into the quickr business card

Many companies are using their corporate LDAP directory to store or to reference the employees’ photo: Some organizations are using a binary LDAP attribute (like the jpegPhoto attribute) to store directly the employee’s photo. Other organizations are using a text LDAP attribute (like the ...

A sample service to retrieve the user's photo from an ldap directory and to display it into the quickr business card

Many companies are using their corporate LDAP directory to store or to reference the employees’ photo: Some organizations are using a binary LDAP attribute (like the jpegPhoto attribute) to store directly the employee’s photo. Other organizations are using a text LDAP attribute (like the ...

Community articleA sample service to retieve the user's photo from an ldap directory and to display it into the quickr business card

Added by vincent vc cailly | Edited by IBM contributor vincent vc cailly on January 5, 2009 | Version 17
expanded Abstract
collapsed Abstract
No abstract provided.
Tags: Quickr, business card, businesscard, LDAP, webservices sample , REST, Customization

Many companies are using their corporate LDAP directory to store or to reference the employees’ photo:

  • Some organizations are using a binary LDAP attribute (like the jpegPhoto attribute) to store directly the employee’s photo.
  • Other organizations are using a text LDAP attribute (like the photoURL attribute ) to store the HTTP url where we can find the employee’s photo.

This article presents a sample of a service that retrieves the user’s photo from an LDAP directory, to display it in the Quickr (Domino Services) business card.

The service is delivered by a servlet named userphoto :

  • The userphoto servlet uses an input XML file, named LDAPConfig.xml , for initializing several variables of the servlet.The path of the LDAPConfig.xml file is passed to the servlet as a servlet init argument. (In this article, we assume that the servlet is executed by the Domino servlet engine of the Quickr server. The domino server hosting Quickr must be configured to use this servlet engine)
  • The userphoto servlet performs an LDAP search request to retrieve and return the user’s photo
  • Then, the Quickr (domino services) qpconfig.xml file is customized to call the servlet in order to display the user’s photo into the the quickr business card

 

How to install this service on a quickr (Domino services) server


Step 1: Update the domino servlets.properties file


 

To update the servlets.properties file, follow these steps:
  1. With your favorite text editor, open the servlets.properties file of your Quickr (Domino services) server.
  2. Add one line as shown in Figure 1.
  3. Save the servlets.properties file
Remarks:
  • The servlets.properties file is located into the domino \data\ directory of the quickr server.
  • The myPath init argument value must match the configuration of your environment .

Figure 1. Updating the servlets properties file

servlet.QuickrSupportUtil.code=com.lotus.quickplace.util.QuickrSupportUtil

servlet.QuickrEntry.code=com.lotus.quickplace.util.QuickrEntry

servlet.QPServlet.code=com.lotus.quickplace.util.QPServlet

servlet.userphoto.initArgs= myPath=C:\\Domqr81\\data\\domino\\servlet\\

 

Step 2 : Create an LDAPconfig.xml file

To create the LDAPconfig.xml file, follow these steps:
  1. Open your favorite text editor and create a LDAPConfig.xml as shown in Figure 2.
  2. Save the file into the directory specified into the myPath init argument of the userphoto servlet (cf. Step1)
Remarks:
  • Values of the LDAPConfig.xml file must match the configuration of your environment. The meaning of each parameter of the LDAPconfig.xml file is detailed below figure 2.

Figure 2. Creating the LDPAConfing.xml file

 

 

Let's clarify the meaning of each parameter of the LDAPconfig.xml file

  • photoAttibute. The LDAP attribute to read to retrieve the user’s photo.
  • photoValue. To specify if the LDAP attribute is a binary attribute containing directly the user’s photo or a text attribute containing an HTTP url for the user’s photo. The value of this parameter must be set either to binary or to link
  • ldapServer. The DNS name of the LDAP server.
  • ldapPort. The TCP port used by the LDAP server.
  • ldapAuth. The authentication method to the LDAP server. The servlet described in this article supports only the simple authentication method.
  • ldapPrincipal. The distinguished name of the LDAP person object to perform the LDAP Bind operation (required if the LDAP rights do not allow to read the attribute specified in the photoAttribute parameter, with an anonymous bind). If no value specified for this parameter, the servlet will perform an anonymous LDAP bind
  • ldapCredentials. The LDAP password associated to the person object used to perform the LDAP Bind operation.
  • SearchFilterAttribute. The LDAP attribute used to build the left side of the LDAP filter for the LDAP search request
  • getParameterValue. The parameter to read into the http query string in order to get the value to be used in the right side of the LDAP filter for the LDAP search request.
  • noEntryJpg. The url of an image to display when the LDAP search request does not return any LDAP entry
  • noPhotoJpg. The url of an image to display when the LDAP search request returns an entry with no value for the attribute specified in the photoAttribute parameter
  • consoleTrace. The purpose if this parameter is for troubleshooting only. If consoleTrace is set to on, values of the servlet’s variables are printed to the domino console.


 

Step 3 : Copy the userphoto.class file into the domino servlet directory

To execute this operation, follow these steps:
  1. Copy the userphoto.class file into into the domino \data\domino\servlet\ directory of the quickr server.
Remarks:
  • The userphoto.class file is attached to this article


 

Step 4 : Post on a Web server images to display when the LDAP request is unable to retrieve the user’s photo.

To execute this operation, follow these steps:
  1. Select an image to display when the LDAP search request does not return any LDAP entry and post it on a web server
  2. Select an image to display when the LDAP search request returns an entry with no value for the attribute specifie d in the photoAttribute parameter.
Remarks:
  • The url of these images must match the noEntryJpg and noPhotoJpg values of the LDAPConfig.xml file


 

Step 5: update the quickr qpconfig.xml file

To update the qpconfig file, follow these steps:
  1. With your favorite text editor, open the qpconfig.xml file of your Quickr (Domino services) server.
  2. Locate the user_photo_source element (a child of the user_directory element) and update it as shown in figure 3.
  3. LDAPConfig.xml
  4. Save the qpconfig.xml file
  5. Restart the HTTP task on the quickr (Domino services) server
Remarks:
  • The qpconfig.xml file is located into the domino \data\ directory of the quickr server.
  • With the example shown in figure 3, we assume that the mail value is used for both SearchFilterAttrib ute and getParameterValue into LDAPConfig.xml


Figure 3. Updating the qpconfig.xml file




 

Screen shots about utilization of this service


 

Call of the service directly from a browser



 

Display of the user’s photo into the Quickr business card (example with the photo stored into the jpegPhoto binary LDAP attribute)



The userphoto servlet source code (userphoto.java)



import java.util.*;
import java.io.*;

import javax.naming.*;
import javax.naming.directory.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.w3c.dom.*;

import java.io.File;
import javax.xml.parsers.*;

public class userphoto extends HttpServlet {

private static final long serialVersionUID = 4986088540795722497L;

public void doGet (final HttpServletRequest request, final HttpServletResponse response) throws IOException
{


define and init variables with default values



final ServletOutputStream out = response.getOutputStream();
String getparam="mail";
String searchfilterattr="mail";
String photoattribute = "jpegphoto";
String photovalue = "binary";
String ldapserver = "localhost";
String ldapport = "389";
String ldapauth = "simple";
String ldapprincipal = "";
With empty values for ldapprincipal and ldapcredentials,
String ldapcredentials = ""; an anonymous LDAP bind xill be peformed
String getparamvalue="";
String noentryjpg="";
String nophotojpg="";
String consoletrace="off";
String ldapuri="";
String filter="";
Element element;
NodeList nodeElementList;



Parse the LDAPConfig.xml file



try {
String myPath = getServletConfig().getInitParameter("myPath");
File file = new File(myPath+"LDAPConfig.xml");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(file);
doc.getDocumentElement().normalize();
NodeList list = doc.getElementsByTagName("config");
for (int i = 0; i < list.getLength(); i++) {
Node node1 = list.item(i);
if (node1.getNodeType() == Node.ELEMENT_NODE) {
element = (Element) node1;
nodeElementList = element.getElementsByTagName("photoAttibute");
photoattribute = ((Node) (((Element) nodeElementList.item(0)).getChildNodes()).item(0)).getNodeValue();
nodeElementList = element.getElementsByTagName("photoValue");
photovalue = ((Node) (((Element) nodeElementList.item(0)).getChildNodes()).item(0)).getNodeValue();
nodeElementList = element.getElementsByTagName("ldapServer");
ldapserver = ((Node) (((Element) nodeElementList.item(0)).getChildNodes()).item(0)).getNodeValue();
nodeElementList = element.getElementsByTagName("ldapPort");
ldapport = ((Node) (((Element) nodeElementList.item(0)) .getChildNodes()).item(0)).getNodeValue();
nodeElementList = element.getElementsByTagName("ldapAuth");
ldapauth = ((Node) (((Element) nodeElementList.item(0)).getChildNodes()).item(0)).getNodeValue();
nodeElementList = element.getElementsByTagName("ldapPrincipal");
ldapprincipal = ((Node) (((Element) nodeElementList.item(0)).getChildNodes()).item(0)).getNodeValue();
nodeElementList = element.getElementsByTagName("ldapCredentials");
ldapcredentials = ((Node) (((Element) nodeElementList.item(0)).getChildNodes()).item(0)).getNodeValue();
nodeElementList = element.getElementsByTagName("SearchFilterAttribute");
searchfilterattr = ((Node) (((Element) nodeElementList.item(0)).getChildNodes()).item(0)).getNodeValue();
nodeElementList = element.getElementsByTagName("getParameterValue");
getparam = ((Node) (((Element) nodeElementList.item(0)).getChildNodes()).item(0)).getNodeValue();
nodeElementList = element.getElementsByTagName("noEntryJpg");
noentryjpg = ((Node) (((Element) nodeElementList.item(0)).getChildNodes()).item(0)).getNodeValue();
nodeE lementList = element.getElementsByTagName("noPhotoJpg");
nophotojpg = ((Node) (((Element) nodeElementList.item(0)).getChildNodes()).item(0)).getNodeValue();
nodeElementList = element.getElementsByTagName("consoleTrace");
consoletrace = ((Node) (((Element) nodeEle mentList.item(0)).getChildNodes()).item(0)).getNodeValue();
}if
}
for
} catch (Exception e) {}



assign variable values



getparamvalue = request.getParameter(getparam);
filter = "("+searchfilterattr+"=" + getparamvalue + ")";
ldapuri= "ldap:
" + ldapserver + ":" + ldapport;



Print variable values to the system console if consoletrace=on



if ( consoletrace.equalsIgnoreCase( "on" ) )
{
System.out.println("getparam :" + getparam);
System.out.println("getparamvalue :" + getparamvalue);
System.out.println("searchfilterattr :" + searchfilterattr);
System.out.println("filter :" + filter);
System.out.println("photoattribute :" + photoattribute);
System.out.println("photovalue :" + photovalue);
System.out.println("ldapserver :" + ldapserver);
System.out.println("ldapport :" + ldapport);
System.out.println("ldapuri :" + ldapuri);
System.out.println("ldapauth :" + ldapauth);
System.out.println("ldapprincipal :" + ldapprincipal);
System.out.println("ldapcredentials :" + ldapcredentials);
System.out.println("noentryjpg :" + noentryjpg);
System.out.println("nophotojpg :" + nophotojpg);
}



Perform the LDAP search request to read the LDAP attribute containing the user's
photo. Then print the output or perform an HTTP redirection to send the user’s
photo



try {
final Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, ldapuri);
env.put(Context.SECURITY_AUTHENTICATION,ldapauth);
env.put(Context.SECURITY_PRINCIPAL,ldapprincipal); specify the username
env.put(Cont ext.SECURITY_CREDENTIALS,ldapcredentials);
specify the password
final DirContext ctx = new InitialDirContext(env);

final SearchControls ctls = new SearchControls();
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); neede d

final String[] attrIDs = {photoattribute};

ctls.setReturningAttributes(attrIDs);
final NamingEnumeration answer = ctx.search("", filter, ctls);
int nbRes = 0;
if (!(answer != null && answer.hasMore() )) {
response.sendRedirect(noentryjpg);
}

while (answer != null && answer.hasMore() && nbRes < 1) {
nbRes++;
final SearchResult sr = (SearchResult)answer.next();
final Attributes attrs = sr.getAttributes();
if (attrs == null) {
response.sendRedirect(nophotojpg);
}
else {
if ( attrs.get(photoattribute) != null)
{
if ( photovalue.equalsIgnoreCase( "link" ) )
{
response.sendRedirect(( String )attrs.get(photoattribute).get(0));
}
else
{
response.setContentType("image/jpeg");
out.write((byte[])attrs.get(photoattribute).get(0));
photo
out.flush();
out.close();
}
}if
else
{
response.sendRedirect(nophotojpg);
}
else
}else
}
while

ctx.close();
try
catch (final Exception e)
{
e.printStackTrace();
}
}
doGetend
}

expanded Attachments (0)
collapsed Attachments (0)
expanded Versions (46)
collapsed Versions (46)
Version Comparison     
VersionDateChanged by              Summary of changes
45Nov 19, 2009 10:46:04 AMKristopher T Stoddard  IBM contributor
44Nov 19, 2009 10:41:37 AMKristopher T Stoddard  IBM contributor
44Nov 10, 2009 9:42:24 PMDana Liburdi  IBM contributor
43Oct 23, 2009 4:58:13 PMvincent vc cailly  IBM contributor
42Aug 17, 2009 9:12:45 AMvincent vc cailly  IBM contributor
41Aug 17, 2009 6:43:19 AMvincent vc cailly  IBM contributor
40Aug 17, 2009 6:33:38 AMvincent vc cailly  IBM contributor
39Aug 17, 2009 6:31:44 AMvincent vc cailly  IBM contributor
38Apr 3, 2009 1:55:42 PMKristopher T Stoddard  IBM contributor
38Aug 17, 2009 6:25:03 AMvincent vc cailly  IBM contributor
37Aug 17, 2009 5:16:12 AMvincent vc cailly  IBM contributor
36Jul 15, 2009 10:29:43 AMKristopher T Stoddard  IBM contributor
34Jan 5, 2009 4:54:29 PMvincent vc cailly  IBM contributor
33Jan 5, 2009 4:27:41 PMvincent vc cailly  IBM contributor
32Jan 5, 2009 4:22:26 PMvincent vc cailly  IBM contributor
31Jan 5, 2009 4:05:01 PMvincent vc cailly  IBM contributor
30Jan 5, 2009 3:59:18 PMvincent vc cailly  IBM contributor
29Jan 5, 2009 3:56:32 PMvincent vc cailly  IBM contributor
28Jan 5, 2009 3:53:04 PMvincent vc cailly  IBM contributor
27Jan 5, 2009 3:49:11 PMvincent vc cailly  IBM contributor
26Jan 5, 2009 3:35:53 PMvincent vc cailly  IBM contributor
25Jan 5, 2009 3:24:35 PMvincent vc cailly  IBM contributor
24Jan 5, 2009 3:19:16 PMvincent vc cailly  IBM contributor
23Jan 5, 2009 3:17:09 PMvincent vc cailly  IBM contributor
22Jan 5, 2009 3:11:19 PMvincent vc cailly  IBM contributor
21Jan 5, 2009 2:44:47 PMvincent vc cailly  IBM contributor
20Jan 5, 2009 2:42:03 PMvincent vc cailly  IBM contributor
19Jan 5, 2009 2:39:12 PMvincent vc cailly  IBM contributor
18Jan 5, 2009 2:35:36 PMvincent vc cailly  IBM contributor
This version (17)Jan 5, 2009 2:32:42 PMvincent vc cailly  IBM contributor
16Jan 5, 2009 2:25:59 PMvincent vc cailly  IBM contributor
15Jan 5, 2009 2:23:07 PMvincent vc cailly  IBM contributor
14Jan 5, 2009 2:20:43 PMvincent vc cailly  IBM contributor
13Jan 5, 2009 1:25:17 PMvincent vc cailly  IBM contributor
12Jan 5, 2009 1:19:32 PMvincent vc cailly  IBM contributor
11Jan 5, 2009 1:17:40 PMvincent vc cailly  IBM contributor
10Jan 5, 2009 1:16:47 PMvincent vc cailly  IBM contributor
9Jan 5, 2009 1:15:52 PMvincent vc cailly  IBM contributor
8Jan 5, 2009 1:13:07 PMvincent vc cailly  IBM contributor
7Jan 5, 2009 1:08:54 PMvincent vc cailly  IBM contributor
6Jan 5, 2009 1:03:42 PMvincent vc cailly  IBM contributor
5Jan 5, 2009 12:59:27 PMvincent vc cailly  IBM contributor
4Jan 5, 2009 12:48:19 PMvincent vc cailly  IBM contributor
3Jan 5, 2009 12:41:53 PMvincent vc cailly  IBM contributor
2Jan 5, 2009 12:26:19 PMvincent vc cailly  IBM contributor
1Jan 5, 2009 12:22:42 PMvincent vc cailly  IBM contributor
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedHelpAbout
  • IBM Collaboration Solutions wikis
  • IBM developerWorks
  • IBM Software support
  • Twitter LinkIBMSocialBizUX on Twitter
  • FacebookIBMSocialBizUX on Facebook
  • ForumsLotus product forums
  • BlogsIBM Social Business UX Blog
  • Community LinkIBM Collaboration Solutions
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Accessibility
  • IBM Terms of use
  • Wiki terms of use