logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: LDAP Authentication
Author
mjh24



Joined: 14 May 2012
Posts: 1

PostPosted: Tue 15 May '12 8:11    Post subject: LDAP Authentication Reply with quote

Hi,

I'm trying to figure out how to authenticate users against LDAP server. The directory server we are using does not allow searching and the authentication must be made by binding a given username to the directory. For the bind a proper username and password are required. The problem is that I don't know how to do this in Apache. The mod_auth_ldap module always tries to search the directory, at least I think so, and that ends up in errors.

I've made a simple Java program to test the authentication and it works. How could I implement this same functionality in Apache? Is it possible using the current modules? Here's the Java code that works:

Code:
public class Attempt {

   public static void main(String[] args) {

      String host = "some.host.com";
      String authType = "simple";
      String baseDN = "";
      String username = "username";      // user inputs this
      String bindPassword = "userpassword";   // user inputs this
      String bindDN = username + "@" + host;      
      
      try {   
         // Environment settings for the connection
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
         env.put(Context.PROVIDER_URL, "LDAP://"+ host +":389/" + baseDN);
         env.put(Context.SECURITY_AUTHENTICATION, authType);
         env.put(Context.SECURITY_PRINCIPAL, bindDN);
         env.put(Context.SECURITY_CREDENTIALS, bindPassword);

         // If this (bind) works the user is authenticated properly
         DirContext ctx = new InitialDirContext(env);
         System.out.println("OK, authentication was succesful");
         
         // Close the connection
         ctx.close();    
         
      } catch(NamingException ne) {
         System.out.println("Error, authentication failed");
      }
   }
}
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Sat 23 Jun '12 14:04    Post subject: Reply with quote

It would help if you post the configuration which you tried with apache.
Back to top


Reply to topic   Topic: LDAP Authentication View previous topic :: View next topic
Post new topic   Forum Index -> Apache