From aad7f10021cdc6bb66a88daa4a4703ea9449fc9b Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Fri, 15 Dec 2006 16:03:35 +0000
Subject: [PATCH] Update the search operation to support returning entries containing the ldapSubEntry objectclass if the filter explicitly contains an "(objectClass=ldapSubEntry)" component.

---
 opends/src/server/org/opends/server/core/SearchOperation.java |   46 +++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/SearchOperation.java b/opends/src/server/org/opends/server/core/SearchOperation.java
index 96c8931..5667eae 100644
--- a/opends/src/server/org/opends/server/core/SearchOperation.java
+++ b/opends/src/server/org/opends/server/core/SearchOperation.java
@@ -64,6 +64,7 @@
 import org.opends.server.types.DisconnectReason;
 import org.opends.server.types.DN;
 import org.opends.server.types.Entry;
+import org.opends.server.types.FilterType;
 import org.opends.server.types.OperationType;
 import org.opends.server.types.ResultCode;
 import org.opends.server.types.SearchFilter;
@@ -842,9 +843,48 @@
     if ((scope != SearchScope.BASE_OBJECT) && (! returnLDAPSubentries) &&
         entry.isLDAPSubentry())
     {
-      // This is a subentry and we should not return it to the client.  Just
-      // throw it away without doing anything.
-      return true;
+      // Check to see if the filter contains an equality element with the
+      // objectclass attribute type and a value of "ldapSubentry".  If so, then
+      // we'll return it anyway.  Technically, this isn't part of the
+      // specification so we don't need to get carried away with really in-depth
+      // checks.
+      switch (filter.getFilterType())
+      {
+        case AND:
+        case OR:
+          for (SearchFilter f : filter.getFilterComponents())
+          {
+            if ((f.getFilterType() == FilterType.EQUALITY) &&
+                (f.getAttributeType().isObjectClassType()))
+            {
+              AttributeValue v = f.getAssertionValue();
+              if (toLowerCase(v.getStringValue()).equals("ldapsubentry"))
+              {
+                returnLDAPSubentries = true;
+              }
+              break;
+            }
+          }
+          break;
+        case EQUALITY:
+          AttributeType t = filter.getAttributeType();
+          if (t.isObjectClassType())
+          {
+            AttributeValue v = filter.getAssertionValue();
+            if (toLowerCase(v.getStringValue()).equals("ldapsubentry"))
+            {
+              returnLDAPSubentries = true;
+            }
+          }
+          break;
+      }
+
+      if (! returnLDAPSubentries)
+      {
+        // We still shouldn't return it even based on the filter.  Just throw it
+        // away without doing anything.
+        return true;
+      }
     }
 
 

--
Gitblit v1.10.0