[jboss-user] [Beginners Corner] - LDAP login

lema do-not-reply at jboss.com
Wed Mar 26 07:51:52 EDT 2008


hallo all,

could anyone, pls, help me with (logging in through) LDAP settings? i've written a part which checks if username&password exist in active directory. But., i've to get usernames of all application users. some users may be in one city, some in another, and infos which the application give are different for each city.

the part which check username&password:

public SmdUser checkLogin(String username, String password) throws Exception {
		try{
            int ldapPort = LDAPConnection.DEFAULT_PORT;
            int ldapVersion = LDAPConnection.LDAP_V3;
            LDAPConnection lc = new LDAPConnection();
    		context = getInitialContext();
    		smsDeliverySecurityRemote = (SmsDeliverySecurityRemote)
    			context.lookup("smsdelivery.security/sms.delivery.security/remote");
            try{
                lc.connect( "ourserver", ldapPort );
                lc.bind(ldapVersion, username+"@kcell.kz", password.getBytes("UTF-8"));
                lc.disconnect();
                SmdUser smdUser = smsDeliverySecurityRemote.getUser(username);
                System.out.println("checkLogin SMDUSER " + smdUser.getName());
                return smdUser;
            }
            catch(LDAPException e){ 
            	System.err.println( "Error: " + e.toString() );
            	return null;
            }
            catch(java.io.UnsupportedEncodingException e ) { 
            	System.out.println( "Error: " + e.toString() );
            	return null;
            }    
        }
        catch(java.lang.NullPointerException e){ 
        	return null;
        }
	}

thanks in advance, lema.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4138936#4138936

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4138936



More information about the jboss-user mailing list