directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r688483 - in /directory/apacheds/trunk: protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java server-integ/src/test/java/org/apache/directory/server/operations/search/SchemaSearchIT.java
Date Sun, 24 Aug 2008 09:46:16 GMT
Author: elecharny
Date: Sun Aug 24 02:46:15 2008
New Revision: 688483

URL: http://svn.apache.org/viewvc?rev=688483&view=rev
Log:
Applied Stefan's fix for DIRSERVER-1234

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SchemaSearchIT.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java?rev=688483&r1=688482&r2=688483&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
Sun Aug 24 02:46:15 2008
@@ -22,12 +22,14 @@
 
 import java.util.concurrent.TimeUnit;
 
+import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.entry.ServerEntryUtils;
 import org.apache.directory.server.core.entry.ServerStringValue;
 import org.apache.directory.server.core.event.EventType;
 import org.apache.directory.server.core.event.NotificationCriteria;
 import org.apache.directory.server.core.filtering.EntryFilteringCursor;
+import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.ldap.LdapSession;
 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
@@ -501,6 +503,16 @@
         }
         
         /*
+         * Do not add the OR'd (objectClass=referral) expression if the user 
+         * searches for the subSchemaSubEntry as the SchemaIntercepter can't 
+         * handle an OR'd filter.
+         */
+        if ( isSubSchemaSubEntrySearch( session, req ) )
+        {
+            return;
+        }
+        
+        /*
          * Most of the time the search filter is just (objectClass=*) and if 
          * this is the case then there's no reason at all to OR this with an
          * (objectClass=referral).  If we detect this case then we leave it 
@@ -632,4 +644,43 @@
         
         return isBaseIsRoot && isBaseScope && isRootDSEFilter;
     }
+    
+    
+    /**
+     * <p>
+     * Determines if a search request is a subSchemaSubEntry search.
+     * </p>
+     * <p>
+     * It is a schema search if:
+     * - the base DN is the DN of the subSchemaSubEntry of the root DSE
+     * - and the scope is BASE OBJECT
+     * - and the filter is (objectClass=subschema)
+     * (RFC 4512, 4.4,)
+     * </p>
+     * <p>
+     * However in this method we only check the first condition to avoid
+     * performance issues.
+     * </p>
+     * 
+     * @param session the LDAP session
+     * @param req the request issued
+     * 
+     * @return true if the search is on the subSchemaSubEntry, false otherwise
+     * 
+     * @throws Exception the exception
+     */
+    private static boolean isSubSchemaSubEntrySearch( LdapSession session, SearchRequest
req ) throws Exception
+    {
+        LdapDN base = req.getBase();
+        String baseNormForm = ( base.isNormalized() ? base.getNormName() : base.toNormName()
);
+
+        DirectoryService ds = session.getCoreSession().getDirectoryService();
+        PartitionNexus nexus = ds.getPartitionNexus();
+        Value<?> subschemaSubentry = nexus.getRootDSE( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT
).get();
+        LdapDN subschemaSubentryDn = new LdapDN( ( String ) ( subschemaSubentry.get() ) );
+        subschemaSubentryDn.normalize( ds.getRegistries().getAttributeTypeRegistry().getNormalizerMapping()
);
+        String subschemaSubentryDnNorm = subschemaSubentryDn.getNormName();
+        
+        return subschemaSubentryDnNorm.equals( baseNormForm );
+    }
 }
\ No newline at end of file

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SchemaSearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SchemaSearchIT.java?rev=688483&r1=688482&r2=688483&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SchemaSearchIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SchemaSearchIT.java
Sun Aug 24 02:46:15 2008
@@ -288,4 +288,39 @@
         assertFalse( results.hasMore() );
         results.close();
     }
+    
+    
+    /**
+     * Test case for DIRSERVER-: Ensure that schema entry is returned, 
+     * even if no ManageDsaIT control is present in the search request.
+     */
+    @Test
+    public void testRequestWithoutManageDsaITControl() throws Exception
+    {
+        DirContext ctx = getWiredContext( ldapServer );
+
+        // this removes the ManageDsaIT control from the search request
+        ctx.addToEnvironment( DirContext.REFERRAL, "throw" );
+
+        SearchControls ctls = new SearchControls();
+        String[] attrNames =
+            { "objectClasses", "attributeTypes", "ldapSyntaxes", "matchingRules", "matchingRuleUse",
"createTimestamp",
+                "modifyTimestamp" };
+        ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        ctls.setReturningAttributes( attrNames );
+
+        NamingEnumeration<SearchResult> result = ctx.search( DN, FILTER, ctls );
+
+        if ( result.hasMore() )
+        {
+            SearchResult entry = result.next();
+            checkForAttributes( entry.getAttributes(), attrNames );
+        }
+        else
+        {
+            fail( "entry " + DN + " not found" );
+        }
+
+        result.close();
+    }
 }



Mime
View raw message