From b892b0038d7dc619ee4fac7058189736d2d73f0d Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Thu, 07 Apr 2011 12:41:00 +0000
Subject: [PATCH] Fix OPENDJ-112 - The Changelog virtual attribute appears in al entries, should only apply to rootDSE. The changes introduce a scope in the VirtualAttributeRule. The default is Whole_Subtree. The changelog virtual attributes are now registered with a BASE_OBJECT scope and "" base DNs, meaning the rootDSE only. Also each virtual attribute provider override the hasValue() method for optimization and avoiding computing the values and throwing them away.

---
 opends/resource/schema/02-config.ldif                                                                                              |    3 
 opends/src/admin/defn/org/opends/server/admin/std/VirtualAttributeConfiguration.xml                                                |   42 +++++
 opends/src/server/org/opends/server/replication/common/LastCookieVirtualProvider.java                                              |    7 
 opends/src/server/org/opends/server/replication/common/LastChangeNumberVirtualAttributeProvider.java                               |   26 ++-
 opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/EntryUUIDVirtualAttributeProviderTestCase.java              |   28 ++-
 opends/src/server/org/opends/server/types/VirtualAttributeRule.java                                                                |   31 +++
 opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/EntryDNVirtualAttributeProviderTestCase.java                |   46 +++-
 opends/src/server/org/opends/server/core/VirtualAttributeConfigManager.java                                                        |   26 ++-
 opends/src/server/org/opends/server/replication/common/ChangelogBaseDNVirtualAttributeProvider.java                                |   24 +-
 opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/IsMemberOfVirtualAttributeProviderTestCase.java             |   34 ++-
 opends/src/server/org/opends/server/replication/server/ReplicationServer.java                                                      |    4 
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java                                 |   67 ++++++++
 opends/src/server/org/opends/server/replication/common/FirstChangeNumberVirtualAttributeProvider.java                              |   24 ++-
 opends/tests/unit-tests-testng/src/server/org/opends/server/types/VirtualAttributeRuleTestCase.java                                |   18 +
 opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/GoverningStructureRuleVirtualAttributeProviderTestCase.java |   28 ++-
 opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/StructuralObjectClassVirtualAttributeProviderTestCase.java  |   28 ++-
 opends/tests/unit-tests-testng/src/server/org/opends/server/types/VirtualAttributeTestCase.java                                    |    2 
 opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SubschemaSubentryVirtualAttributeProviderTestCase.java      |   28 ++-
 18 files changed, 355 insertions(+), 111 deletions(-)

diff --git a/opends/resource/schema/02-config.ldif b/opends/resource/schema/02-config.ldif
index 51680d4..4d84b61 100644
--- a/opends/resource/schema/02-config.ldif
+++ b/opends/resource/schema/02-config.ldif
@@ -22,7 +22,7 @@
 #
 #
 #      Copyright 2006-2010 Sun Microsystems, Inc.
-#      Portions Copyright 2010 ForgeRock AS.
+#      Portions Copyright 2010-2011 ForgeRock AS.
 #
 #
 # This file contains the attribute type and objectclass definitions for use
@@ -3461,6 +3461,7 @@
          ds-cfg-enabled $
          ds-cfg-attribute-type )
   MAY ( ds-cfg-base-dn $
+        ds-cfg-scope $
         ds-cfg-group-dn $
         ds-cfg-filter $
         ds-cfg-conflict-behavior )
diff --git a/opends/src/admin/defn/org/opends/server/admin/std/VirtualAttributeConfiguration.xml b/opends/src/admin/defn/org/opends/server/admin/std/VirtualAttributeConfiguration.xml
index 382d5b0..cb2d2b6 100644
--- a/opends/src/admin/defn/org/opends/server/admin/std/VirtualAttributeConfiguration.xml
+++ b/opends/src/admin/defn/org/opends/server/admin/std/VirtualAttributeConfiguration.xml
@@ -24,6 +24,7 @@
   !
   !
   !      Copyright 2007-2008 Sun Microsystems, Inc.
+  !      Portions Copyright 2011 ForgeRock AS
   ! -->
 <adm:managed-object name="virtual-attribute"
   plural-name="virtual-attributes" package="org.opends.server.admin.std"
@@ -126,6 +127,47 @@
       </ldap:attribute>
     </adm:profile>
   </adm:property>
+  <adm:property name="scope">
+    <adm:synopsis>
+      Specifies the LDAP scope associated with base DNs for entries that are
+      eligible to use this virtual attribute.
+    </adm:synopsis>
+    <adm:default-behavior>
+      <adm:defined>
+        <adm:value>whole-subtree</adm:value>
+      </adm:defined>
+    </adm:default-behavior>
+    <adm:syntax>
+      <adm:enumeration>
+        <adm:value name="base-object">
+          <adm:synopsis>Search the base object only.</adm:synopsis>
+        </adm:value>
+        <adm:value name="single-level">
+          <adm:synopsis>
+            Search the immediate children of the base object but do not 
+            include any of their descendants or the base object itself.
+          </adm:synopsis>
+        </adm:value>
+        <adm:value name="subordinate-subtree">
+          <adm:synopsis>
+            Search the entire subtree below the base object but do not
+            include the base object itself.
+          </adm:synopsis>
+        </adm:value>
+        <adm:value name="whole-subtree">
+          <adm:synopsis>
+            Search the base object and the entire subtree below the base
+            object.
+          </adm:synopsis>
+        </adm:value>
+      </adm:enumeration>
+    </adm:syntax>
+    <adm:profile name="ldap">
+      <ldap:attribute>
+        <ldap:name>ds-cfg-scope</ldap:name>
+      </ldap:attribute>
+    </adm:profile>
+  </adm:property>
   <adm:property name="group-dn" multi-valued="true">
     <adm:synopsis>
       Specifies the DNs of the groups whose members can be eligible to
diff --git a/opends/src/server/org/opends/server/core/VirtualAttributeConfigManager.java b/opends/src/server/org/opends/server/core/VirtualAttributeConfigManager.java
index ee6da9a..325cc0b 100644
--- a/opends/src/server/org/opends/server/core/VirtualAttributeConfigManager.java
+++ b/opends/src/server/org/opends/server/core/VirtualAttributeConfigManager.java
@@ -23,8 +23,10 @@
  *
  *
  *      Copyright 2007-2009 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 package org.opends.server.core;
+import org.opends.server.types.SearchScope;
 import org.opends.messages.Message;
 
 
@@ -188,8 +190,10 @@
 
           VirtualAttributeRule rule =
                new VirtualAttributeRule(cfg.getAttributeType(), provider,
-                                        cfg.getBaseDN(), cfg.getGroupDN(),
-                                        filters, cfg.getConflictBehavior());
+                     cfg.getBaseDN(),
+                     SearchScope.valueOf(cfg.getScope().name()),
+                     cfg.getGroupDN(),
+                     filters, cfg.getConflictBehavior());
           rules.put(cfg.dn(), rule);
           DirectoryServer.registerVirtualAttribute(rule);
         }
@@ -324,10 +328,11 @@
     {
       VirtualAttributeRule rule =
            new VirtualAttributeRule(configuration.getAttributeType(), provider,
-                                    configuration.getBaseDN(),
-                                    configuration.getGroupDN(),
-                                    filters,
-                                    configuration.getConflictBehavior());
+                 configuration.getBaseDN(),
+                 SearchScope.valueOf(configuration.getScope().name()),
+                 configuration.getGroupDN(),
+                 filters,
+                 configuration.getConflictBehavior());
 
       rules.put(configuration.dn(), rule);
       DirectoryServer.registerVirtualAttribute(rule);
@@ -506,10 +511,11 @@
     {
       VirtualAttributeRule rule =
            new VirtualAttributeRule(configuration.getAttributeType(), provider,
-                                    configuration.getBaseDN(),
-                                    configuration.getGroupDN(),
-                                    filters,
-                                    configuration.getConflictBehavior());
+                 configuration.getBaseDN(),
+                 SearchScope.valueOf(configuration.getScope().name()),
+                 configuration.getGroupDN(),
+                 filters,
+                 configuration.getConflictBehavior());
 
       rules.put(configuration.dn(), rule);
       if (existingRule == null)
diff --git a/opends/src/server/org/opends/server/replication/common/ChangelogBaseDNVirtualAttributeProvider.java b/opends/src/server/org/opends/server/replication/common/ChangelogBaseDNVirtualAttributeProvider.java
index 1f899e6..1129459 100644
--- a/opends/src/server/org/opends/server/replication/common/ChangelogBaseDNVirtualAttributeProvider.java
+++ b/opends/src/server/org/opends/server/replication/common/ChangelogBaseDNVirtualAttributeProvider.java
@@ -23,11 +23,11 @@
  *
  *
  *      Copyright 2009 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 package org.opends.server.replication.common;
 
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -57,6 +57,15 @@
        extends VirtualAttributeProvider<UserDefinedVirtualAttributeCfg>
        implements ConfigurationChangeListener<UserDefinedVirtualAttributeCfg>
 {
+
+  /*
+   * The base DN of the changelog is a constant.
+   * TODO: This shouldn't be a virtual attribute, but directly
+   * registered in the RootDSE.
+   */
+  private final Set<AttributeValue> values;
+
+
   /**
    * Creates a new instance of this member virtual attribute provider.
    */
@@ -64,8 +73,11 @@
   {
     super();
 
-    // All initialization should be performed in the
-    // initializeVirtualAttributeProvider method.
+    AttributeValue value =
+    AttributeValues.create(
+        ByteString.valueOf(ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT),
+        ByteString.valueOf(ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT));
+    values=Collections.singleton(value);
   }
 
 
@@ -111,12 +123,6 @@
   @Override()
   public Set<AttributeValue> getValues(Entry entry,VirtualAttributeRule rule)
   {
-    Set<AttributeValue> values = new HashSet<AttributeValue>();
-    AttributeValue value =
-      AttributeValues.create(
-          ByteString.valueOf(ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT),
-          ByteString.valueOf(ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT));
-    values=Collections.singleton(value);
     return values;
   }
 
diff --git a/opends/src/server/org/opends/server/replication/common/FirstChangeNumberVirtualAttributeProvider.java b/opends/src/server/org/opends/server/replication/common/FirstChangeNumberVirtualAttributeProvider.java
index 9c84ad1..7e84adc 100644
--- a/opends/src/server/org/opends/server/replication/common/FirstChangeNumberVirtualAttributeProvider.java
+++ b/opends/src/server/org/opends/server/replication/common/FirstChangeNumberVirtualAttributeProvider.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2009 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 package org.opends.server.replication.common;
 
@@ -30,7 +31,6 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -48,7 +48,6 @@
 import org.opends.server.types.AttributeValues;
 import org.opends.server.types.ByteString;
 import org.opends.server.types.ConfigChangeResult;
-import org.opends.server.types.DN;
 import org.opends.server.types.DebugLogLevel;
 import org.opends.server.types.Entry;
 import org.opends.server.types.InitializationException;
@@ -120,6 +119,16 @@
   }
 
 
+  /**
+   *  {@inheritDoc}
+   */
+  @Override
+  public boolean hasValue(Entry entry, VirtualAttributeRule rule)
+  {
+    // There's only a value for the rootDSE, i.e. the Null DN.
+    return entry.getDN().isNullDN();
+  }
+
 
   /**
    * {@inheritDoc}
@@ -127,14 +136,9 @@
   @Override()
   public Set<AttributeValue> getValues(Entry entry,VirtualAttributeRule rule)
   {
-    Set<AttributeValue> values = new HashSet<AttributeValue>();
     String first="0";
     try
     {
-      if (!entry.getDN().equals(DN.decode("")))
-      {
-        return values;
-      }
       ECLWorkflowElement eclwe = (ECLWorkflowElement)
       DirectoryServer.getWorkflowElement("EXTERNAL CHANGE LOG");
       if (eclwe!=null)
@@ -157,13 +161,17 @@
     }
     catch(Exception e)
     {
+      // We got an error computing the first change number.
+      // Rather than returning 0 which is no change, return -1 to
+      // indicate the error.
+      first = "-1";
       TRACER.debugCaught(DebugLogLevel.ERROR, e);
     }
     AttributeValue value =
       AttributeValues.create(
           ByteString.valueOf(first),
           ByteString.valueOf(first));
-    values=Collections.singleton(value);
+    Set<AttributeValue> values=Collections.singleton(value);
     return values;
   }
 
diff --git a/opends/src/server/org/opends/server/replication/common/LastChangeNumberVirtualAttributeProvider.java b/opends/src/server/org/opends/server/replication/common/LastChangeNumberVirtualAttributeProvider.java
index 510d5dd..0ca12bc 100644
--- a/opends/src/server/org/opends/server/replication/common/LastChangeNumberVirtualAttributeProvider.java
+++ b/opends/src/server/org/opends/server/replication/common/LastChangeNumberVirtualAttributeProvider.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2009 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 package org.opends.server.replication.common;
 
@@ -30,7 +31,6 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -48,7 +48,6 @@
 import org.opends.server.types.AttributeValues;
 import org.opends.server.types.ByteString;
 import org.opends.server.types.ConfigChangeResult;
-import org.opends.server.types.DN;
 import org.opends.server.types.DebugLogLevel;
 import org.opends.server.types.Entry;
 import org.opends.server.types.InitializationException;
@@ -120,19 +119,26 @@
 
 
   /**
+   *  {@inheritDoc}
+   */
+  @Override
+  public boolean hasValue(Entry entry, VirtualAttributeRule rule)
+  {
+    // There's only a value for the rootDSE, i.e. the Null DN.
+    return entry.getDN().isNullDN();
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
   @Override()
   public Set<AttributeValue> getValues(Entry entry,VirtualAttributeRule rule)
   {
-    Set<AttributeValue> values = new HashSet<AttributeValue>();
     String last = "0";
     try
     {
-      if (!entry.getDN().equals(DN.decode("")))
-      {
-        return values;
-      }
       ECLWorkflowElement eclwe = (ECLWorkflowElement)
       DirectoryServer.getWorkflowElement("EXTERNAL CHANGE LOG");
       if (eclwe!=null)
@@ -154,13 +160,17 @@
     }
     catch(Exception e)
     {
+      // We got an error computing the first change number.
+      // Rather than returning 0 which is no change, return -1 to
+      // indicate the error.
+      last = "-1";
       TRACER.debugCaught(DebugLogLevel.ERROR, e);
     }
     AttributeValue value =
       AttributeValues.create(
           ByteString.valueOf(last),
           ByteString.valueOf(last));
-    values=Collections.singleton(value);
+    Set<AttributeValue> values =Collections.singleton(value);
     return values;
   }
 
diff --git a/opends/src/server/org/opends/server/replication/common/LastCookieVirtualProvider.java b/opends/src/server/org/opends/server/replication/common/LastCookieVirtualProvider.java
index 9ead5f7..da4335c 100644
--- a/opends/src/server/org/opends/server/replication/common/LastCookieVirtualProvider.java
+++ b/opends/src/server/org/opends/server/replication/common/LastCookieVirtualProvider.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2009 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 
 package org.opends.server.replication.common;
@@ -104,10 +105,8 @@
   @Override()
   public boolean hasValue(Entry entry, VirtualAttributeRule rule)
   {
-    // Indicates whether this virtual attribute provider will generate
-    // at least one value for the provided entry.
-    // True is the DN is the one of the root DSE : "".
-    return entry.getDN().toNormalizedString().equalsIgnoreCase("");
+    // There's only a value for the rootDSE, i.e. the Null DN.
+    return entry.getDN().isNullDN();
 
   }
 
diff --git a/opends/src/server/org/opends/server/replication/server/ReplicationServer.java b/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
index 4358278..be198cf 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -91,6 +91,7 @@
 import org.opends.server.workflowelement.externalchangelog.ECLWorkflowElement;
 
 import com.sleepycat.je.DatabaseException;
+import org.opends.server.types.SearchScope;
 
 /**
  * ReplicationServer Listener.
@@ -690,7 +691,8 @@
       baseDNs.add(DN.decode(""));
       VirtualAttributeRule rule =
         new VirtualAttributeRule(attributeType, provider,
-            baseDNs, groupDNs, filters, conflictBehavior);
+              baseDNs, SearchScope.BASE_OBJECT,
+              groupDNs, filters, conflictBehavior);
 
       DirectoryServer.registerVirtualAttribute(rule);
     }
diff --git a/opends/src/server/org/opends/server/types/VirtualAttributeRule.java b/opends/src/server/org/opends/server/types/VirtualAttributeRule.java
index 10809f1..7966e1e 100644
--- a/opends/src/server/org/opends/server/types/VirtualAttributeRule.java
+++ b/opends/src/server/org/opends/server/types/VirtualAttributeRule.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2008 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 package org.opends.server.types;
 
@@ -71,6 +72,10 @@
   // virtual attribute.
   private final Set<DN> baseDNs;
 
+  // The scope of entries eligible to have this virtual attribute,
+  // under the base DNs.
+  private final SearchScope scope;
+
   // The set of DNs for groups whose members are eligible to have this
   // virtual attribute.
   private final Set<DN> groupDNs;
@@ -101,6 +106,9 @@
    * @param  baseDNs           The set of base DNs for branches that
    *                           are eligible to have this virtual
    *                           attribute.
+   * @param  scope             The scope of entries, related to the
+   *                           base DNs, that are eligible to have
+   *                           this virtual attribute.
    * @param  groupDNs          The set of DNs for groups whose members
    *                           are eligible to have this virtual
    *                           attribute.
@@ -115,7 +123,7 @@
   public VirtualAttributeRule(AttributeType attributeType,
               VirtualAttributeProvider<? extends VirtualAttributeCfg>
                    provider,
-              Set<DN> baseDNs, Set<DN> groupDNs,
+              Set<DN> baseDNs, SearchScope scope, Set<DN> groupDNs,
               Set<SearchFilter> filters,
               VirtualAttributeCfgDefn.ConflictBehavior
                    conflictBehavior)
@@ -126,6 +134,7 @@
     this.attributeType    = attributeType;
     this.provider         = provider;
     this.baseDNs          = baseDNs;
+    this.scope            = scope;
     this.groupDNs         = groupDNs;
     this.filters          = filters;
     this.conflictBehavior = conflictBehavior;
@@ -176,6 +185,19 @@
   }
 
 
+  /**
+   * Retrieves the scope of entries in the base DNs that are eligible
+   * to have this virtual attribute.
+   *
+   * @return  The scope of entries that are eligible to
+   *          have this virtual attribute.
+   */
+  public SearchScope getScope()
+  {
+    return scope;
+  }
+
+
 
   /**
    * Retrieves the set of DNs for groups whose members are eligible to
@@ -254,7 +276,7 @@
       boolean found = false;
       for (DN dn : baseDNs)
       {
-        if (entryDN.isDescendantOf(dn))
+        if (entryDN.matchesBaseAndScope(dn , scope))
         {
           found = true;
           break;
@@ -378,8 +400,9 @@
 
       buffer.append("\"");
     }
-
-    buffer.append("}, groupDNs={");
+    buffer.append("}, scope=");
+    buffer.append(scope.toString());
+    buffer.append(", groupDNs={");
     if (! groupDNs.isEmpty())
     {
       buffer.append("\"");
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/EntryDNVirtualAttributeProviderTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/EntryDNVirtualAttributeProviderTestCase.java
index 28f6384..b6fbc77 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/EntryDNVirtualAttributeProviderTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/EntryDNVirtualAttributeProviderTestCase.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2008-2009 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 package org.opends.server.extensions;
 
@@ -545,7 +546,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryDNType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -580,7 +582,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryDNType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -612,7 +615,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryDNType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -645,7 +649,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryDNType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -677,7 +682,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryDNType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -710,7 +716,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryDNType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -745,7 +752,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryDNType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -780,7 +788,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryDNType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -817,7 +826,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryDNType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -854,7 +864,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryDNType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -890,7 +901,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryDNType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -924,7 +936,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryDNType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -958,7 +971,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryDNType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -1025,7 +1039,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryDNType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -1076,7 +1091,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryDNType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/EntryUUIDVirtualAttributeProviderTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/EntryUUIDVirtualAttributeProviderTestCase.java
index f187d93..99b88fa 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/EntryUUIDVirtualAttributeProviderTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/EntryUUIDVirtualAttributeProviderTestCase.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2008-2009 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 package org.opends.server.extensions;
 
@@ -561,7 +562,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryUUIDType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -596,7 +598,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryUUIDType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -630,7 +633,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryUUIDType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -664,7 +668,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryUUIDType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -696,7 +701,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryUUIDType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -731,7 +737,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryUUIDType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -766,7 +773,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryUUIDType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -803,7 +811,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryUUIDType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -840,7 +849,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(entryUUIDType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/GoverningStructureRuleVirtualAttributeProviderTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/GoverningStructureRuleVirtualAttributeProviderTestCase.java
index ef30b65..75cd40e 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/GoverningStructureRuleVirtualAttributeProviderTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/GoverningStructureRuleVirtualAttributeProviderTestCase.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2009 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 package org.opends.server.extensions;
 
@@ -608,7 +609,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(governingStructureRuleType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -644,7 +646,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(governingStructureRuleType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -676,7 +679,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(governingStructureRuleType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -709,7 +713,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(governingStructureRuleType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -742,7 +747,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(governingStructureRuleType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -775,7 +781,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(governingStructureRuleType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -810,7 +817,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(governingStructureRuleType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -845,7 +853,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(governingStructureRuleType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -882,7 +891,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(governingStructureRuleType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/IsMemberOfVirtualAttributeProviderTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/IsMemberOfVirtualAttributeProviderTestCase.java
index 8913e25..d9c4e94 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/IsMemberOfVirtualAttributeProviderTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/IsMemberOfVirtualAttributeProviderTestCase.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2008-2009 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 package org.opends.server.extensions;
 
@@ -587,7 +588,8 @@
          new IsMemberOfVirtualAttributeProvider();
     VirtualAttributeRule rule =
          new VirtualAttributeRule(isMemberOfType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -651,7 +653,8 @@
          new IsMemberOfVirtualAttributeProvider();
     VirtualAttributeRule rule =
          new VirtualAttributeRule(isMemberOfType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -718,7 +721,8 @@
          new IsMemberOfVirtualAttributeProvider();
     VirtualAttributeRule rule =
          new VirtualAttributeRule(isMemberOfType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -785,7 +789,8 @@
          new IsMemberOfVirtualAttributeProvider();
     VirtualAttributeRule rule =
          new VirtualAttributeRule(isMemberOfType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -854,7 +859,8 @@
          new IsMemberOfVirtualAttributeProvider();
     VirtualAttributeRule rule =
          new VirtualAttributeRule(isMemberOfType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -898,7 +904,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(isMemberOfType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -934,7 +941,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(isMemberOfType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -968,7 +976,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(isMemberOfType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -1002,7 +1011,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(isMemberOfType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -1097,7 +1107,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(isMemberOfType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -1224,7 +1235,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(isMemberOfType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/StructuralObjectClassVirtualAttributeProviderTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/StructuralObjectClassVirtualAttributeProviderTestCase.java
index afb8571..3944f6f 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/StructuralObjectClassVirtualAttributeProviderTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/StructuralObjectClassVirtualAttributeProviderTestCase.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2009 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 package org.opends.server.extensions;
 
@@ -576,7 +577,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(structuralObjectClassType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -612,7 +614,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(structuralObjectClassType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -644,7 +647,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(structuralObjectClassType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -678,7 +682,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(structuralObjectClassType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -711,7 +716,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(structuralObjectClassType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -744,7 +750,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(structuralObjectClassType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -779,7 +786,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(structuralObjectClassType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -814,7 +822,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(structuralObjectClassType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -852,7 +861,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(structuralObjectClassType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SubschemaSubentryVirtualAttributeProviderTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SubschemaSubentryVirtualAttributeProviderTestCase.java
index 7e3383a..055c33d 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SubschemaSubentryVirtualAttributeProviderTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/SubschemaSubentryVirtualAttributeProviderTestCase.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2008-2009 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 package org.opends.server.extensions;
 
@@ -554,7 +555,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(subschemaSubentryType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -590,7 +592,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(subschemaSubentryType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -622,7 +625,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(subschemaSubentryType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -656,7 +660,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(subschemaSubentryType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -689,7 +694,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(subschemaSubentryType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -722,7 +728,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(subschemaSubentryType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -757,7 +764,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(subschemaSubentryType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -792,7 +800,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(subschemaSubentryType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
@@ -830,7 +839,8 @@
 
     VirtualAttributeRule rule =
          new VirtualAttributeRule(subschemaSubentryType, provider,
-                  Collections.<DN>emptySet(), Collections.<DN>emptySet(),
+                  Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE,
+                  Collections.<DN>emptySet(),
                   Collections.<SearchFilter>emptySet(),
                   VirtualAttributeCfgDefn.ConflictBehavior.
                        VIRTUAL_OVERRIDES_REAL);
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
index 1d56757..0a55d0b 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
@@ -243,10 +243,15 @@
     // Test all types of ops.
     ECLAllOps(); // Do not clean the db for the next test
 
+    // Test that ECL Operational, virtual attributes are not visible
+    // outside rootDSE. Next test will test access in RootDSE.
+    // This one checks in data.
+    ECLOperationalAttributesFailTest();
+
     // First and last should be ok whenever a request has been done or not
     // in compat mode.
     ECLCompatTestLimits(1,4,true);replicationServer.clearDb();
-
+    
     // Test with a mix of domains, a mix of DSes
     ECLTwoDomains(); replicationServer.clearDb();
 
@@ -285,6 +290,11 @@
     // Test all types of ops.
     ECLAllOps(); // Do not clean the db for the next test
 
+    // Test that ECL Operational, virtual attributes are not visible
+    // outside rootDSE. Next test will test access in RootDSE.
+    // This one checks in data.
+    ECLOperationalAttributesFailTest();
+
     // First and last should be ok whenever a request has been done or not
     // in compat mode.
     ECLCompatTestLimits(1,4, true);replicationServer.clearDb();
@@ -3510,6 +3520,61 @@
     }
     debugInfo(tn, "Ending test with success");
   }
+  
+  private void ECLOperationalAttributesFailTest()
+  {
+    String tn = "ECLOperationalAttributesFailTest";
+    // The goal is to verify that the Changelog attributes are not
+    // available in other entries. We u
+    debugInfo(tn, "Starting test \n\n");
+    try
+    {
+      LinkedHashSet<String> attributes = new LinkedHashSet<String>();
+      
+      attributes.add("firstchangenumber");
+      attributes.add("lastchangenumber");
+      attributes.add("changelog");
+      attributes.add("lastExternalChangelogCookie");
+
+      debugInfo(tn, " Search: "+ TEST_ROOT_DN_STRING);
+      InternalSearchOperation searchOp =
+        connection.processSearch(
+            ByteString.valueOf(TEST_ROOT_DN_STRING),
+            SearchScope.BASE_OBJECT,
+            DereferencePolicy.NEVER_DEREF_ALIASES,
+            0, // Size limit
+            0, // Time limit
+            false, // Types only
+            LDAPFilter.decode("(objectclass=*)"),
+            attributes,
+            NO_CONTROL,
+            null);
+      waitOpResult(searchOp, ResultCode.SUCCESS);
+      assertEquals(searchOp.getSearchEntries().size(), 1);
+      
+      LinkedList<SearchResultEntry> entries = searchOp.getSearchEntries();
+      assertEquals(entries.size(), 1);
+      for (SearchResultEntry resultEntry : entries)
+      {
+          debugInfo(tn, "Result entry returned:" + resultEntry.toLDIFString());
+          assertEquals(getAttributeValue(resultEntry, "firstchangenumber"),
+                null);
+          assertEquals(getAttributeValue(resultEntry, "lastchangenumber"),
+                null);
+          assertEquals(getAttributeValue(resultEntry, "changelog"),
+                null);
+          assertEquals(getAttributeValue(resultEntry, "lastExternalChangelogCookie"),
+                null);
+      }
+  
+      debugInfo(tn, "Ending test with success");
+    }
+    catch(Exception e)
+    {
+      fail("Ending "+tn+" test with exception:\n"
+          +  stackTraceToSingleLineString(e));
+    }
+  }
 
   private void ECLCompatTestLimits(int expectedFirst, int expectedLast,
       boolean eclEnabled)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/types/VirtualAttributeRuleTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/types/VirtualAttributeRuleTestCase.java
index 39cbf1e..c7bf4ee 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/types/VirtualAttributeRuleTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/types/VirtualAttributeRuleTestCase.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2008 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 package org.opends.server.types;
 
@@ -134,6 +135,7 @@
       {
         new VirtualAttributeRule(entryDNType, provider,
                                  Collections.<DN>emptySet(),
+                                 SearchScope.WHOLE_SUBTREE,
                                  Collections.<DN>emptySet(),
                                  Collections.<SearchFilter>emptySet(),
                                  ConflictBehavior.VIRTUAL_OVERRIDES_REAL),
@@ -143,6 +145,7 @@
       new Object[]
       {
         new VirtualAttributeRule(entryDNType, provider, dnSet1,
+                                 SearchScope.WHOLE_SUBTREE,
                                  Collections.<DN>emptySet(),
                                  Collections.<SearchFilter>emptySet(),
                                  ConflictBehavior.VIRTUAL_OVERRIDES_REAL),
@@ -152,6 +155,7 @@
       new Object[]
       {
         new VirtualAttributeRule(entryDNType, provider, dnSet2,
+                                 SearchScope.WHOLE_SUBTREE,
                                  Collections.<DN>emptySet(),
                                  Collections.<SearchFilter>emptySet(),
                                  ConflictBehavior.VIRTUAL_OVERRIDES_REAL),
@@ -161,6 +165,7 @@
       new Object[]
       {
         new VirtualAttributeRule(entryDNType, provider, dnSet3,
+                                 SearchScope.WHOLE_SUBTREE,
                                  Collections.<DN>emptySet(),
                                  Collections.<SearchFilter>emptySet(),
                                  ConflictBehavior.VIRTUAL_OVERRIDES_REAL),
@@ -170,7 +175,8 @@
       new Object[]
       {
         new VirtualAttributeRule(entryDNType, provider,
-                                 Collections.<DN>emptySet(), groupSet1,
+                                 Collections.<DN>emptySet(),
+                                 SearchScope.WHOLE_SUBTREE, groupSet1,
                                  Collections.<SearchFilter>emptySet(),
                                  ConflictBehavior.VIRTUAL_OVERRIDES_REAL),
         true
@@ -179,7 +185,8 @@
       new Object[]
       {
         new VirtualAttributeRule(entryDNType, provider,
-                                 Collections.<DN>emptySet(), groupSet2,
+                                 Collections.<DN>emptySet(),
+                                 SearchScope.WHOLE_SUBTREE, groupSet2,
                                  Collections.<SearchFilter>emptySet(),
                                  ConflictBehavior.VIRTUAL_OVERRIDES_REAL),
         false
@@ -188,7 +195,8 @@
       new Object[]
       {
         new VirtualAttributeRule(entryDNType, provider,
-                                 Collections.<DN>emptySet(), groupSet3,
+                                 Collections.<DN>emptySet(),
+                                 SearchScope.WHOLE_SUBTREE, groupSet3,
                                  Collections.<SearchFilter>emptySet(),
                                  ConflictBehavior.VIRTUAL_OVERRIDES_REAL),
         true
@@ -198,6 +206,7 @@
       {
         new VirtualAttributeRule(entryDNType, provider,
                                  Collections.<DN>emptySet(),
+                                 SearchScope.WHOLE_SUBTREE,
                                  Collections.<DN>emptySet(), filterSet1,
                                  ConflictBehavior.VIRTUAL_OVERRIDES_REAL),
         true
@@ -207,6 +216,7 @@
       {
         new VirtualAttributeRule(entryDNType, provider,
                                  Collections.<DN>emptySet(),
+                                 SearchScope.WHOLE_SUBTREE,
                                  Collections.<DN>emptySet(), filterSet2,
                                  ConflictBehavior.VIRTUAL_OVERRIDES_REAL),
         true
@@ -216,6 +226,7 @@
       {
         new VirtualAttributeRule(entryDNType, provider,
                                  Collections.<DN>emptySet(),
+                                 SearchScope.WHOLE_SUBTREE,
                                  Collections.<DN>emptySet(), filterSet3,
                                  ConflictBehavior.VIRTUAL_OVERRIDES_REAL),
         false
@@ -225,6 +236,7 @@
       {
         new VirtualAttributeRule(entryDNType, provider,
                                  Collections.<DN>emptySet(),
+                                 SearchScope.WHOLE_SUBTREE,
                                  Collections.<DN>emptySet(), filterSet4,
                                  ConflictBehavior.VIRTUAL_OVERRIDES_REAL),
         true
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/types/VirtualAttributeTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/types/VirtualAttributeTestCase.java
index f80c70b..d92353e 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/types/VirtualAttributeTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/types/VirtualAttributeTestCase.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2008-2009 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 package org.opends.server.types;
 
@@ -77,6 +78,7 @@
 
     virtualAttributeRule = new VirtualAttributeRule(entryDNType, provider,
                                     Collections.<DN>emptySet(),
+                                    SearchScope.WHOLE_SUBTREE,
                                     Collections.<DN>emptySet(),
                                     Collections.<SearchFilter>emptySet(),
                                     ConflictBehavior.VIRTUAL_OVERRIDES_REAL);

--
Gitblit v1.10.0