Menu

The ApacheDS does not return any warning message

2017-03-29
2017-03-29
  • Pasquale Maiorano

    I am using the following classes to retrieve the errors and , if any, the warning related tp the Implemented Password Policy. Unfortunately, It returns only the errors :
    Password expired and Account locked
    The code I used is the following:

        public void ldapExceptionHandling(LDAPException exception){
    
            System.out.println("sono in LDAPException");
            BindResult bindResult = new BindResult(exception);
    
            try {
                    DraftBeheraLDAPPasswordPolicy10ResponseControl pwpResponse =
                            DraftBeheraLDAPPasswordPolicy10ResponseControl.get(bindResult);
    
                    if (pwpResponse == null){
                        System.out.println("pwpResponse == null");
                        LOG.error(exception.getMessage(), exception);
                        JOptionPane.showMessageDialog(null,
                                "Error during authentication process.",
                                "ERROR",
                                JOptionPane.ERROR_MESSAGE);
    
                    }
                    else{
    
                        DraftBeheraLDAPPasswordPolicy10WarningType warningType = pwpResponse.getWarningType();
    
                        DraftBeheraLDAPPasswordPolicy10ErrorType errorType = pwpResponse.getErrorType();
    
                        if (warningType != null)
                        {
                            // There was a password policy warning.
                            int value = pwpResponse.getWarningValue();
                            switch (warningType)
                            {
                            case TIME_BEFORE_EXPIRATION:
                                System.out.println("The warning value is the number of seconds until expiration : "  + value);
                                break;
                            case GRACE_LOGINS_REMAINING:
                                System.out.println("The warning value is the number of grace logins remaining : " + value);
                            }
                        }else{
    
                            System.out.println("Warning è null");
                        }
    
                        if (errorType != null)
                        {
                            switch (errorType)
                            {
                            /**
                             * The error type that indicates the user's password is expired.
                             */
                            case PASSWORD_EXPIRED:
                                System.out.println("The error type that indicates the user's password is expired.");
                                LOG.error(exception.getMessage(), exception);
                                JOptionPane.showMessageDialog(null,
                                        exception.getResultString(),
                                        "ERROR",
                                        JOptionPane.ERROR_MESSAGE);
    
                                break;
    
                                /**
                                 * The error type that indicates the user's account is locked or disabled.
                                 */
                            case ACCOUNT_LOCKED:
                                System.out.println("The error type that indicates the user's account is locked or disabled.");
                                System.out.println("Diagnosti message: " + exception.getDiagnosticMessage());
                                LOG.error(exception.getMessage(), exception);
                                JOptionPane.showMessageDialog(null,
                                        exception.getResultString(),
                                        "ERROR",
                                        JOptionPane.ERROR_MESSAGE);
                                break;
    
                                /**
                                 * The error type that indicates the user's password must be changed before
                                 * any other operation will be allowed.
                                 */
                            case CHANGE_AFTER_RESET:
                                System.out.println("The error type that indicates the user's password must be changed");
                                break;
    
                                /**
                                 * The error type that indicates that user password changes aren't allowed.
                                 */
                            case PASSWORD_MOD_NOT_ALLOWED:
                                System.out.println("The error type that indicates that user password changes aren't allowed.");
                                break;
    
                                /**
                                 * The error type that indicates the user must provide the current password
                                 * when attempting to set a new one.
                                 */
                            case MUST_SUPPLY_OLD_PASSWORD:
                                System.out.println("The error type that indicates the user must provide the current password");
                                break;
    
                                /**
                                 * The error type that indicates the proposed password is too weak to be
                                 * acceptable.
                                 */
                            case INSUFFICIENT_PASSWORD_QUALITY:
                                System.out.println("The error type that indicates the proposed password is too weak to be acceptable");
                                break;
    
                                /**
                                 * The error type that indicates the proposed password is too short.
                                 */
                            case PASSWORD_TOO_SHORT:
                                System.out.println("The error type that indicates the proposed password is too short.");
                                break;
    
                                /**
                                 * The error type that indicates the user's password cannot be changed because
                                 * it has not been long enough since it was last changed.
                                 */
                            case  PASSWORD_TOO_YOUNG:
                                System.out.println("The error type that indicates the user's password cannot be changed because"
                                        + "it has not been long enough since it was last changed.");
                                break;
    
                                /**
                                 * The error type that indicates the proposed password is already in the
                                 * password history.
                                 */
                            case PASSWORD_IN_HISTORY:
                                System.out.println("The error type that indicates the proposed password is already in the password history.");
                                break;
    
                            }
                        }
    
                }
            } catch (LDAPException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    
       I Knows that is a little bit off topic, because is more related to ApachDs then the library, but any help will be really appriciated.
    
       Regards,
    
       Pasquale
    
     
  • Neil Wilson

    Neil Wilson - 2017-03-29

    Yeah, this is something that you’ll probably have to ask the ApacheDS people. The LDAP SDK can only interpret what the server sends back, and the fact that it’s doing it in some cases does suggest that it’s doing its job. If you think the server should be sending a control back but it isn’t, or if the server is sending a control back that doesn’t contain what you expect to find in it, then that’s a server-side problem, and the LDAP SDK can’t help you there.

    The only thing I can help you with is if you think that the server might be sending the information back, but the LDAP SDK isn’t interpreting it correctly. If you think that might be the case, then you can send me a network packet capture that includes the bind response, and I’ll be happy take a look at it to see if it does contain the expected information but encoded in a way that the LDAP SDK doesn’t expect. But since I don’t know anything about ApacheDS, I can’t help you with a problem in which it’s not sending the information at all.

    Neil

     
  • Pasquale Maiorano

    thank you any how, Neil.Unfortunately the ApacheDS peoples are not so availbel as you. There is not any discussion channel where to post any problem.
    Regards,
    Pasquale

     

Log in to post a comment.