Author: akarasulu Date: Wed Aug 24 15:12:20 2005 New Revision: 239951 URL: http://svn.apache.org/viewcvs?rev=239951&view=rev Log: added code to test on compare operations if the attribute being compared is not defined within the schema or not present. In these cases the proper error codes of undefinedAttributeType and noSuchAttribute respectively are returned. This fix is for DIREVE-226 and the issue is here: http://issues.apache.org/jira/browse/DIREVE-226 Modified: directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java Modified: directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java?rev=239951&r1=239950&r2=239951&view=diff ============================================================================== --- directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java (original) +++ directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java Wed Aug 24 15:12:20 2005 @@ -28,6 +28,9 @@ import org.apache.ldap.common.message.LdapResultImpl; import org.apache.ldap.common.message.ResultCodeEnum; import org.apache.ldap.common.util.ExceptionUtils; +import org.apache.ldap.common.schema.AttributeType; +import org.apache.ldap.server.jndi.ContextFactoryService; +import org.apache.ldap.server.schema.AttributeTypeRegistry; import org.apache.mina.protocol.ProtocolSession; import org.apache.mina.protocol.handler.MessageHandler; import org.slf4j.Logger; @@ -54,10 +57,16 @@ { DirContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true ); Attribute attr = ctx.getAttributes( req.getName() ).get( req.getAttributeId() ); + AttributeTypeRegistry registry = ContextFactoryService.getInstance(). + getConfiguration().getGlobalRegistries().getAttributeTypeRegistry(); - if ( attr == null ) + if ( ! registry.hasAttributeType( req.getAttributeId() ) ) { - resp.getLdapResult().setResultCode( ResultCodeEnum.COMPAREFALSE ); + resp.getLdapResult().setResultCode( ResultCodeEnum.UNDEFINEDATTRIBUTETYPE ); + } + else if ( attr == null ) + { + resp.getLdapResult().setResultCode( ResultCodeEnum.NOSUCHATTRIBUTE ); } else if ( attr.contains( req.getAssertionValue() ) ) {