/** * * Synchronously checks to see if an entry contains an attribute * with a specified value. * * @param dn The distinguished name of the entry to use in the * comparison. *<br><br> * @param attr The attribute to compare against the entry. The * method checks to see if the entry has an * attribute with the same name and value as this * attribute. * * @return True if the entry has the value, * and false if the entry does not * have the value or the attribute. * * @exception LDAPException A general exception which includes an error * message and an LDAP error code. */ public boolean compare(String dn, LDAPAttribute attr) throws LDAPException { return compare(dn, attr, defSearchCons); }
throws LDAPException return compare(dn, attr, queue, defSearchCons);
/** * Check if provided password is correct provided users's password. * * @param userDN the user. * @param password the password. * @param passwordField the name of the LDAP field containing the password. * @return true if the password is valid, false otherwise. */ public boolean checkPassword(String userDN, String password, String passwordField) { try { LDAPAttribute attribute = new LDAPAttribute(passwordField, password); return this.connection.compare(userDN, attribute); } catch (LDAPException e) { if (e.getResultCode() == LDAPException.NO_SUCH_OBJECT) { if (LOG.isDebugEnabled()) { LOG.debug("Unable to locate user_dn:" + userDN, e); } } else if (e.getResultCode() == LDAPException.NO_SUCH_ATTRIBUTE) { if (LOG.isDebugEnabled()) { LOG.debug("Unable to verify password because userPassword attribute not found.", e); } } else { if (LOG.isDebugEnabled()) { LOG.debug("Unable to verify password", e); } } } return false; }
/** * Check if provided password is correct provided users's password. * * @param userDN the user. * @param password the password. * @param passwordField the name of the LDAP field containing the password. * @return true if the password is valid, false otherwise. */ public boolean checkPassword(String userDN, String password, String passwordField) { try { LDAPAttribute attribute = new LDAPAttribute(passwordField, password); return this.connection.compare(userDN, attribute); } catch (LDAPException e) { if (e.getResultCode() == LDAPException.NO_SUCH_OBJECT) { LOGGER.debug("Unable to locate user_dn [{}]", userDN, e); } else if (e.getResultCode() == LDAPException.NO_SUCH_ATTRIBUTE) { LOGGER.debug("Unable to verify password because userPassword attribute not found.", e); } else { LOGGER.debug("Unable to verify password", e); } } return false; }
try compareResult = connection.compare(compareRequest); if (compareResult.compareMatched())
/** * * Synchronously checks to see if an entry contains an attribute * with a specified value. * * @see <a href="../../../../api/com/novell/ldap/LDAPConnection.html#compare(java.lang.String, com.novell.ldap.LDAPAttribute)"> com.novell.ldap.LDAPConnection.compare(String, LDAPAttribute)</a> */ public boolean compare(String dn, LDAPAttribute attr) throws LDAPException { try { return conn.compare( dn, attr.getWrappedObject()); } catch( com.novell.ldap.LDAPException ex) { if( ex instanceof com.novell.ldap.LDAPReferralException) { throw new LDAPReferralException( (com.novell.ldap.LDAPReferralException)ex); } else { throw new LDAPException( ex); } } }
/** * Checks to see if an entry contains an attribute with a specified * value, using the specified constraints. * * @see <a href="../../../../api/com/novell/ldap/LDAPConnection.html#compare(java.lang.String, com.novell.ldap.LDAPAttribute, com.novell.ldap.LDAPConstraints)"> com.novell.ldap.LDAPConnection.compare(String, LDAPAttribute, LDAPConstraints)</a> */ public boolean compare(String dn, LDAPAttribute attr, LDAPConstraints cons) throws LDAPException { try { return conn.compare( dn, attr.getWrappedObject(), cons.getWrappedObject()); } catch( com.novell.ldap.LDAPException ex) { if( ex instanceof com.novell.ldap.LDAPReferralException) { throw new LDAPReferralException( (com.novell.ldap.LDAPReferralException)ex); } else { throw new LDAPException( ex); } } }
/** * Asynchronously compares an attribute value with one in the directory, * using the specified queue. * * @see <a href="../../../../api/com/novell/ldap/LDAPConnection.html#compare(java.lang.String, com.novell.ldap.LDAPAttribute, com.novell.ldap.LDAPResponseQueue)"> com.novell.ldap.LDAPConnection.compare(String, LDAPAttribute, LDAPResponseQueue)</a> */ public LDAPResponseQueue compare(String dn, LDAPAttribute attr, LDAPResponseQueue queue) throws LDAPException { try { return new LDAPResponseQueue( conn.compare( dn, attr.getWrappedObject(), queue.getWrappedObject())); } catch( com.novell.ldap.LDAPException ex) { if( ex instanceof com.novell.ldap.LDAPReferralException) { throw new LDAPReferralException( (com.novell.ldap.LDAPReferralException)ex); } else { throw new LDAPException( ex); } } }
conn.compare( dn, attr.getWrappedObject(), queue.getWrappedObject(),
"compare(" + dn + ") if value"); LDAPResponseQueue queue = compare(dn, attr, null, cons);