title: Integrating LDAP with Application (Jasper on tomcat)
body: <p>I am working on integrating my reporting app with LDAP, I modified a few beans in the applicationContext-externalAuth-LDAP.xml as per the documentation</p>
  
  <p>1) ldapContextSource</p>
  
  <pre><code>&lt;bean id="ldapContextSource" class="com.jaspersoft.jasperserver.api.security.externalAuth.ldap.JSLdapContextSource"&gt;
          &lt;constructor-arg value="ldap://url.ldap.com:3268/DC=main,DC=com"/&gt;
          &lt;!-- manager user name and password (may not be needed)  --&gt;
          &lt;property name="userDn" value="CN=Account Name,OU=Support User Account,DC=main,DC=com"/&gt;
          &lt;property name="password" value="123xyz"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>2) userSearch bean</p>
  
  <pre><code>    &lt;bean id="userSearch"
            class="com.jaspersoft.jasperserver.api.security.externalAuth.wrappers.spring.ldap.JSFilterBasedLdapUserSearch"&gt;
          &lt;constructor-arg index="0"&gt;
              &lt;value&gt;(&amp;amp;(|(objectClass=contact)(objectClass=user))(objectCategory=person)(cn={0})(|(memberOf=CN=VPN-Access,CN=Users,DC=Main,DC=com)(memberOf=CN=All,CN=Disto,CN=Users,DC=main,DC=com)))&lt;/value&gt;
          &lt;/constructor-arg&gt;
          &lt;constructor-arg index="1"&gt;
              &lt;value&gt;(&amp;amp;(sAMAccountName={0}))&lt;/value&gt;
          &lt;/constructor-arg&gt;
          &lt;constructor-arg index="2"&gt;
              &lt;ref local="ldapContextSource" /&gt;
          &lt;/constructor-arg&gt;
          &lt;property name="searchSubtree"&gt;
              &lt;value&gt;true&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>I tested the above search string connection using jexplorer and it successfully retrieved my users. </p>
  
  <p>The error I'm getting when I deploy this to my app is. Any ideas as to what the root cause of this would be or the solution would be greatly appreciated:</p>
  
  <pre><code>org.springframework.security.authentication.InternalAuthenticationServiceException: Failed to parse DN; nested exception is org.springframework.ldap.core.TokenMgrError: Lexical error at line 1, column 1.  Encountered: "(" (40), after : ""
  Caused by: org.springframework.ldap.BadLdapGrammarException: Failed to parse DN; nested exception is org.springframework.ldap.core.TokenMgrError: Lexical error at line 1, column 1.  Encountered: "(" (40), after : ""
  Caused by: org.springframework.ldap.core.TokenMgrError: Lexical error at line 1, column 1.  Encountered: "(" (40), after : ""```
  </code></pre>