I'm trying to figure out how to authenticate users against LDAP server. The directory server 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 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:

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
		} catch(NamingException ne) {
			System.out.println("Error, authentication failed");