Accessing Directory Server from Flex application using Java and LDAP is pretty straight forward. All you need to do is to create a Java class which will access your Directory Server using LDAP and return the results. In this sample I used the following to access Directory Server from my Flex application.
Netscape Directory SDK for Java: I used this to access Directory Server from my Java class.
BlazeDS Remoting: used this for accessing Java class from Flex application.
We will create one Java class which will search Directory Server and return the values. MXML file to access the Java class and display the results.
Pre-requisite: Knowledge on how to invoke Java methods from Flex applications and also have BlazeDS set up on your server. If you have not done this, please visit this URL for details on how to access Java methods from Flex applications. Invoking Java methods from Flex applications
Download this file at this URL: LDAPHelper.java
We have a searchEmployees() method which will search the Directory Server and returns ArrayList. You have to edit the attached file to add your server name and credentials to access your Directory Server. searchEmployees() method is not doing much, check out the dev guide to learn more about how to play around with Directory Server.
You should add a destination to your remoting-config.xml. I have added the following under the service tag in my remoting-config.xml.
<destination id=” LDAPHelper” channels=”my-amf”>
You should add the Netscape Directory SDK for Java jar file into the WEB-INF/lib folder of the web application and also to your project in the Eclipse for compiling the class.
Download this file at this URL: LDAPSearch.mxml
In this application we are invoking the searchEmployees() method on the Java class using BlazeDS Remoting and displaying the results returned.