13.07.2015 Views

The LDAP Join Control - UnboundID

The LDAP Join Control - UnboundID

The LDAP Join Control - UnboundID

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Code Comparison: Search JNDI:Search<strong>Control</strong>s search<strong>Control</strong>s = new Search<strong>Control</strong>s();search<strong>Control</strong>s.setSearchScope(Search<strong>Control</strong>s.SUBTREE_SCOPE);search<strong>Control</strong>s.setReturningAttributes(new String[] { "mail" });String mail = null;NamingEnumeration results = conn.search("dc=example,dc=com", "(uid=test)", search<strong>Control</strong>s);try {SearchResult result = results.next();Attributes attributes = result.getAttributes();Attribute mailAttr = attributes.get("mail");if (mailAttr != null) {Object o = mailAttr.get();if (o != null) {if (o instanceof byte[]) {mail = new String((byte[]) o, "UTF-8");} else {mail = String.valueOf(o);}}}} finally {results.close();}Confusing class nameAttribute values are objectsand you need to figure outthe typeDon't forget to closethe NamingEnumeration!14

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!