Hi,

I am a LDAP weenie so some of these questions may be dumb but ...

* How come you recreate Dir/Contexts multiple times instead of caching them
? Is it more efficient to reconnect because only rarely add/remove check or
some other reason ?

* How come you cache some variables in setConfiguration instead of directly
placing them in a Hasntable/env ? Ease of debugging or something else ?

* In code below you check a password by logging as a principle - why don't
you just log in as super-user (cached connection) and read the password and
compare ?

------------------------------------------------------------------------
            Hashtable env2 = new Hashtable();
            env2.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
            env2.put(javax.naming.Context.PROVIDER_URL, rootURL);
            env2.put(javax.naming.Context.SECURITY_AUTHENTICATION, "simple");
            env2.put(javax.naming.Context.SECURITY_PRINCIPAL, userDN);
            env2.put(javax.naming.Context.SECURITY_CREDENTIALS, testPassword);
            //System.out.println("Creating initial context from " + baseURL);
  
            try {
                DirContext testCtx = new InitialDirContext(env2);
                result = true;
                testCtx.close();
            
            } catch (AuthenticationException ae) {
                result = false;
             logger.log("Attempt to authenticate with incorrect password for " +
name + " : " + ae , "UserManager", logger.ERROR);
             //System.out.println("Attempt to authenticate with incorrect
password for " + name + " : " + ae);
                //System.out.println(ae.getMessage());
                //ae.printStackTrace();
            } catch (Exception e) {
                  logger.log("Problem checking password for " + name + " : " + e ,
"UserManager", logger.ERROR);
                  //System.out.println("Problem checking password for " + name + " : "
+ e);
                  //System.out.println(e.getMessage());
                  //e.printStackTrace();
            }
------------------------------------------------------------------------

* Isn't the below code really slow if you say have users in the vacinity of
3000 or so ? If so is there anyway in LDAP to get around it ? Is there
anyway countUsers can be deprecated as a required method as it seems
incredibly expensive ? Perhaps by returning an Iterator ?

------------------------------------------------------------------------
   public int countUsers() {
       
         String[] attrIDs = {membersAttr};
         int result = -1;
  
        try {
            Attribute members = ctx.getAttributes("", attrIDs).get(membersAttr);
            if (members != null) {
                result = members.size();
            } else {
                result = 0;
            }
------------------------------------------------------------------------


Anyways as I said I know nothing about LDAP so be kind :P

        

Cheers,

Pete

*------------------------------------------------------*
| "Nearly all men can stand adversity, but if you want |
| to test a man's character, give him power."          |
|       -Abraham Lincoln                               |
*------------------------------------------------------*


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives:  <http://www.mail-archive.com/james%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to