From c549b645f5300bed76e62614e0137c7eecc2e067 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Thu, 16 Jul 2026 07:48:20 +0000
Subject: [PATCH] [#738] Fix dereferencing an alias that points into another backend (#741)

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java
index 50506e3..40b0c0f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java
@@ -13,7 +13,7 @@
  *
  * Copyright 2007-2010 Sun Microsystems, Inc.
  * Portions Copyright 2013-2016 ForgeRock AS.
- * Portions Copyright 2025 3A Systems, LLC
+ * Portions Copyright 2025-2026 3A Systems, LLC
  */
 package org.opends.server.backends.pluggable;
 
@@ -123,12 +123,28 @@
    */
   private EntryContainer accessBegin(Operation operation, DN entryDN) throws DirectoryException
   {
+    return accessBegin(operation, entryDN, ResultCode.UNDEFINED);
+  }
+
+  /**
+   * Begin a Backend API method that accesses the {@link EntryContainer} for <code>entryDN</code>
+   * and returns it.
+   * @param operation requesting the storage
+   * @param entryDN the target DN for the operation
+   * @param noEntryContainerResultCode the result code to report when this backend holds no
+   *                                   entry container for <code>entryDN</code>
+   * @return <code>EntryContainer</code> where <code>entryDN</code> resides
+   */
+  private EntryContainer accessBegin(Operation operation, DN entryDN, ResultCode noEntryContainerResultCode)
+      throws DirectoryException
+  {
     checkRootContainerInitialized();
     rootContainer.checkForEnoughResources(operation);
     EntryContainer ec = rootContainer.getEntryContainer(entryDN);
     if (ec == null)
     {
-      throw new DirectoryException(ResultCode.UNDEFINED, ERR_BACKEND_ENTRY_DOESNT_EXIST.get(entryDN, getBackendID()));
+      throw new DirectoryException(
+          noEntryContainerResultCode, ERR_BACKEND_ENTRY_DOESNT_EXIST.get(entryDN, getBackendID()));
     }
     threadTotalCount.getAndIncrement();
     return ec;
@@ -557,7 +573,9 @@
   @Override
   public void search(SearchOperation searchOperation) throws DirectoryException, CanceledOperationException
   {
-    EntryContainer ec = accessBegin(searchOperation, searchOperation.getBaseDN());
+    // a base DN held by no entry container of this backend does not exist as far as a client
+    // is concerned: report it as such instead of the UNDEFINED result code used internally.
+    EntryContainer ec = accessBegin(searchOperation, searchOperation.getBaseDN(), ResultCode.NO_SUCH_OBJECT);
 
     ec.sharedLock.lock();
 

--
Gitblit v1.10.0