File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JBoss/WildFly and the fly likes How to configure LDAP in JBoss AS 7.1.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "How to configure LDAP in JBoss AS 7.1.1" Watch "How to configure LDAP in JBoss AS 7.1.1" New topic

How to configure LDAP in JBoss AS 7.1.1

Nagaraju Nookala

Joined: Mar 19, 2004
Posts: 23
How can I configure LDAP server connection in JBoss AS 7.1.1. I won't be using LDAP for authenticating the users logging in to the web application. I need to query the LDAP server configured in JBoss AS 7.1.1 (standalone.xml file is used for this, I guess), using a java class to retrieve the user information.

I have the following code that I use without using JBoss configuration, which works fine:

public class LdapContextCreation {
public static void main(String[] args) {
LdapContextCreation ldapContxCrtn = new LdapContextCreation();
LdapContext ctx = ldapContxCrtn.getLdapContext();
public LdapContext getLdapContext(){
LdapContext ctx = null;
Hashtable env = new Hashtable();
env.put(Context.SECURITY_AUTHENTICATION, "Simple");
env.put(Context.SECURITY_PRINCIPAL, "cn=Manager, dc=maxcrc,dc=com");
env.put(Context.SECURITY_CREDENTIALS, "secret");
env.put(Context.PROVIDER_URL, "ldap://localhost:389");
ctx = new InitialLdapContext(env, null);
System.out.println("Connection Successful.");
String base = "ou=People,dc=maxcrc,dc=com";
SearchControls sc = new SearchControls();
String[] attributeFilter = { "cn", "mail", "givenName", "sn", "initials", "telephoneNumber" };

String filter = "(&(sn=N*))";

NamingEnumeration results =, filter, sc);
while (results.hasMore()) {
SearchResult sr = (SearchResult);
Attributes attrs = sr.getAttributes();

Attribute attr = attrs.get("cn");
System.out.print("Common Name: " + attr.get());
attr = attrs.get("mail");
System.out.print("\nEmail Address: " + attr.get());
attr = attrs.get("givenName");
System.out.print("\nGiven Name: " + attr.get());
attr = attrs.get("sn");
System.out.print("\nSurname: " + attr.get());
attr = attrs.get("initials");
System.out.print("\nInitials: " + attr.get());
attr = attrs.get("telephoneNumber");
System.out.println("\nTelephone Number: " + attr.get());

}catch(NamingException nex){
System.out.println("LDAP Connection: FAILED");
return ctx;


Can somebody please help me how to configure LDAP server in JBoss AS 7.1.1 and how can that be read by a java class to connect to the LDAP server to retrieve the user information. I also read about 'SecureIdentityLogin' module to encrypt the password. Can somebody please help me in using the encrypted password in the configuration.

Thanks in advance for the help.
I agree. Here's the link:
subject: How to configure LDAP in JBoss AS 7.1.1
It's not a secret anymore!