• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to configure LDAP in JBoss AS 7.1.1  RSS feed

Nagaraju Nookala
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 = ctx.search(base, filter, sc);
while (results.hasMore()) {
SearchResult sr = (SearchResult) results.next();
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!