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 2017/04/12 08:29:52 UTC

[2/3] camel git commit: CAMEL-11060: fall back on base DN specified on Spring LDAP context source if none is defined in the URI

CAMEL-11060: fall back on base DN specified on Spring LDAP context source if none is defined in the URI


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/152916a7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/152916a7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/152916a7

Branch: refs/heads/master
Commit: 152916a772769414dbb8c1dce02304d7e2a88174
Parents: 49f2bb5
Author: Ken Geis <kg...@berkeley.edu>
Authored: Tue Apr 4 11:34:22 2017 -0700
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Apr 12 10:26:18 2017 +0200

----------------------------------------------------------------------
 .../camel/component/springldap/SpringLdapProducer.java   | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/152916a7/components/camel-spring-ldap/src/main/java/org/apache/camel/component/springldap/SpringLdapProducer.java
----------------------------------------------------------------------
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 23e2779..84259c4 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
@@ -27,8 +27,10 @@ import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.ldap.core.AttributesMapper;
+import org.springframework.ldap.core.ContextSource;
 import org.springframework.ldap.core.LdapOperations;
 import org.springframework.ldap.core.LdapTemplate;
+import org.springframework.ldap.core.support.BaseLdapPathContextSource;
 import org.springframework.ldap.query.LdapQueryBuilder;
 
 public class SpringLdapProducer extends DefaultProducer {
@@ -89,12 +91,19 @@ public class SpringLdapProducer extends DefaultProducer {
             throw new UnsupportedOperationException("LDAP operation must not be empty, but you provided an empty operation");
         }
 
+        LdapTemplate ldapTemplate = endpoint.getLdapTemplate();
+
         String dn = (String)body.get(DN);
+        if (StringUtils.isBlank(dn)) {
+            ContextSource contextSource = ldapTemplate.getContextSource();
+            if (contextSource instanceof BaseLdapPathContextSource) {
+		dn = ((BaseLdapPathContextSource) contextSource).getBaseLdapPathAsString();
+	    }
+        }
         if (operation != LdapOperation.FUNCTION_DRIVEN && (StringUtils.isBlank(dn))) {
             throw new UnsupportedOperationException("DN must not be empty, but you provided an empty DN");
         }
 
-        LdapOperations ldapTemplate = endpoint.getLdapTemplate();
         switch (operation) {
         case SEARCH:
             String filter = (String)body.get(FILTER);