You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/04/24 14:26:17 UTC

[camel] branch main updated: CAMEL-19293: set dn only once (#9914)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 397bb163024 CAMEL-19293: set dn only once (#9914)
397bb163024 is described below

commit 397bb163024eac1cbf05ca0ba1820cd50a51e30a
Author: Federico Mariani <34...@users.noreply.github.com>
AuthorDate: Mon Apr 24 16:26:09 2023 +0200

    CAMEL-19293: set dn only once (#9914)
---
 .../camel/component/springldap/SpringLdapProducer.java       | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/components/camel-spring-ldap/src/main/java/org/apache/camel/component/springldap/SpringLdapProducer.java b/components/camel-spring-ldap/src/main/java/org/apache/camel/component/springldap/SpringLdapProducer.java
index 47735631f8b..bf11a2f4b67 100644
--- a/components/camel-spring-ldap/src/main/java/org/apache/camel/component/springldap/SpringLdapProducer.java
+++ b/components/camel-spring-ldap/src/main/java/org/apache/camel/component/springldap/SpringLdapProducer.java
@@ -93,13 +93,15 @@ public class SpringLdapProducer extends DefaultProducer {
         LdapTemplate ldapTemplate = endpoint.getLdapTemplate();
 
         String dn = (String) body.get(DN);
-        if (ObjectHelper.isEmpty(dn)) {
-            ContextSource contextSource = ldapTemplate.getContextSource();
-            if (contextSource instanceof BaseLdapPathContextSource) {
-                dn = ((BaseLdapPathContextSource) contextSource).getBaseLdapPathAsString();
+        boolean dnSetOnLdapTemplate = false;
+        ContextSource contextSource = ldapTemplate.getContextSource();
+        if (contextSource instanceof BaseLdapPathContextSource) {
+            if (ObjectHelper.isNotEmpty(((BaseLdapPathContextSource) contextSource).getBaseLdapPathAsString())) {
+                dn = ""; // DN already set on the ldapTemplate
+                dnSetOnLdapTemplate = true;
             }
         }
-        if (operation != LdapOperation.FUNCTION_DRIVEN && (ObjectHelper.isEmpty(dn))) {
+        if (operation != LdapOperation.FUNCTION_DRIVEN && ObjectHelper.isEmpty(dn) && !dnSetOnLdapTemplate) {
             throw new UnsupportedOperationException("DN must not be empty, but you provided an empty DN");
         }