Practical Spring LDAP: Enterprise Java LDAP Development Made Easy (Expert's Voice in Spring)

Practical Spring LDAP: Enterprise Java LDAP Development Made Easy (Expert's Voice in Spring)

Balaji Varanasi

Language: English

Pages: 216

ISBN: 1430263970

Format: PDF / Kindle (mobi) / ePub


Practical Spring LDAP is your guide to developing Java-based enterprise applications using the Spring LDAP Framework. This book explains the purpose and fundamental concepts of LDAP before giving a comprehensive tour of the latest version, Spring LDAP 1.3.2. It provides a detailed treatment of LDAP controls and the new features of Spring LDAP 1.3.2 such as Object Directory Mapping and LDIF parsing.

LDAP has become the de-facto standard for storing and accessing information in enterprises. Despite its widespread adoption, developers often struggle when it comes to using this technology effectively. The traditional JNDI approach has proven to be painful and has resulted in complex, less modular applications. The Spring LDAP Framework provides an ideal alternative.

 

 

 

 

 

 

 

 

 

 

 

 

Cast(source. toString()); } return result; } }   Next, you need an implementation to convert the LDAP string attribute to Java PhoneNumber type. To do this, you create the ToPhoneNumberConverter, as shown in Listing 8-23. Listing 8-23. package com. inflinx. book. ldap. custom;   import org. springframework. ldap. odm. typeconversion. impl. Converter;   public class ToPhoneNumberConverter implements Converter {   @Override public T convert(Object source, Class toClass) throws Exception { T result = null; if(String.

Sorted = result;   Integer code = (Integer) invokeMethod("getResultCode", responseControlClass, control); this. resultCode = code; }   Now that you have created a new DirContextProcessor instance that allows you to sort on multiple attributes, let’s take it for a spin. Listing 7-9 shows a sort method that uses the SortMultipleControlDirContextProcessor. The method uses the attributes st and l for sorting the results. Listing 7-9. public void sortByLocation() {   String[] locationAttributes = {"st", "l"}; SortMultipleControlDirContextProcessor smcdcp = new SortMultipleControlDir ContextProcessor(locationAttributes); SearchControls searchControls = new SearchControls(); searchControls.

PrintStackTrace(); } finally { closeContext(context); } } { Removing an Entry Removing an entry using JNDI is again a straightforward process and is shown in Listing 2-8. The destroySubcontext method takes the fully qualified DN of the entry that needs to be deleted. 22 CHAPTER 2 ■ Java Support for LDAP Listing 2-8. public void remove(String dn) { DirContext context = null; try { context = getContext(); context. destroySubcontext(dn); } catch(NamingException e) { e. printStackTrace();  finally { closeContext(context); } }   Many LDAP servers don’t allow an entry to be deleted if it has child entries.

3. 6. 1. 4. 1. 4203. 1. 10. 2 2. 16. 840. 1. 113730. 3. 4. 12 2. 16. 840. 1. 113730. 3. 4. 16 2. 16. 840. 1. 113730. 3. 4. 17 2. 16. 840. 1. 113730. 3. 4. 18 2. 16. 840. 1. 113730. 3. 4. 19 2. 16. 840. 1. 113730. 3. 4. 2 2. 16. 840. 1. 113730. 3. 4. 3 2. 16. 840. 1. 113730. 3. 4. 4 2. 16. 840. 1. 113730. 3. 4. 5 2. 16. 840. 1. 113730. 3. 4. 9   The OpenDJ installation provides a command line ldapsearch tool that can also be used for listing the supported controls. Assuming that OpenDJ is installed under c:\practicalldap\opendj on Windows, here is the command to get a list of supported controls:   ldapsearch --baseDN "" --searchScope base --port 11389 "(objectclass=*)" supportedControl   Figure 7-3 displays the results of running this command.

InitialLdapContext; import javax. naming. ldap. LdapContext; import com. inflinx. book. ldap. domain. Patron;   public class JndiObjectFactoryLookupExample {   private LdapContext getContext() throws NamingException { Properties environment = new Properties(); environment. setProperty(DirContext. INITIAL_CONTEXT_FACTORY, "com. sun. jndi. ldap. LdapCtxFactory"); environment. setProperty(DirContext. PROVIDER_URL, "ldap://localhost:11389"); environment. setProperty(DirContext. SECURITY_PRINCIPAL, "cn=Directory Manager"); environment.

Download sample

Download

Rated 4.11 of 5 – based on 46 votes