Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 10th, 2012, 04:47 AM
mjh24 mjh24 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 2 mjh24 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 44 m 53 sec
Reputation Power: 0
general - Apache authentication

Hi,

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:

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");
		}
	}
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > general - Apache authentication

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap