From 4371795418de3f7908de0a4dfc4a05707d28fb38 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Tue, 14 Apr 2009 09:30:13 +0000
Subject: [PATCH] Fix issue 3638 - Referrals not properly managed for bind operations

---
 opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java |   16 ++++++++++++++--
 opends/tests/unit-tests-testng/src/server/org/opends/server/core/BindOperationTestCase.java     |    2 +-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java
index 666173a..bd7b9b7 100644
--- a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java
+++ b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java
@@ -545,8 +545,20 @@
         }
 
         userEntry = null;
-        throw new DirectoryException(ResultCode.INVALID_CREDENTIALS,
-                                     de.getMessageObject());
+
+        if (de.getResultCode() == ResultCode.REFERRAL)
+        {
+          // Re-throw referral exceptions - these should be passed back
+          // to the client.
+          throw de;
+        }
+        else
+        {
+          // Replace other exceptions in case they expose any sensitive
+          // information.
+          throw new DirectoryException(ResultCode.INVALID_CREDENTIALS,
+              de.getMessageObject());
+        }
       }
 
       if (userEntry == null)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/core/BindOperationTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/core/BindOperationTestCase.java
index 5c74730..b127eb9 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/core/BindOperationTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/core/BindOperationTestCase.java
@@ -1860,7 +1860,7 @@
    *
    * @throws  Exception  If an unexpected problem occurs.
    */
-  @Test(enabled=false)
+  @Test()
   public void testSimpleBindReferral()
          throws Exception
   {

--
Gitblit v1.10.0