2 Replies Latest reply on Mar 27, 2008 6:40 AM by sara isa

    LDAP login

    sara isa Newbie

      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.

        • 1. Re: LDAP login
          sara isa Newbie

          before setting the application security to LDAP, i used to do it like:

          String username = getThreadLocalRequest().getRemoteUser();

          and could get city of the username.

          • 2. Re: LDAP login
            sara isa Newbie

            someone at work said that i've to save usernames (data) in a session in servlet. so that, each user will be able to see only his/her info.
            the problem i'm facing now is, all logged in users have to use the info of the user logged in last.

            oh good guys, please help..