Accessing Directory Server from Flex using Java

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.

Directory SDK Dev guide

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

LDAPHelper.java

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”>

<properties>

<source> com.adobe.ldap.LDAPHelper</source>

</properties>

<adapter ref=”java-object”/>

</destination>

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.

LDAPSearch.mxml

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.

That’s it🙂

2 Responses to Accessing Directory Server from Flex using Java

  1. […] G. is a fantastic blogger with quite a few good articles on data services. I found his blog while search of information on custom messaging adapters. I […]

  2. p lakshmi says:

    pls give ur phone no. and address to communicate

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: