title: How do I set up Tomcat with authentication in LDAP?
body: <blockquote>
  <p>&quot;How to use LDAP for authentication in Tomcat with Custom
  Authorization&quot;</p>
  <p>&quot;LDAP authentication via web.xml in Tomcat&quot;</p>
  <p>&quot;LDAP Authentication Requirements and How to do it&quot;</p>
  </blockquote>
  <p>I seem to not be the only one struggling with this issue.
  With the current configuration, I can authenticate with my LDAP users and not with system or tomcat users. The problem is that whenever I'm logged in, I'm denied access to the files I should see.</p>
  <p>I currently have a web.xml with the following info</p>
  <pre><code>&lt;security-constraint&gt;
  &lt;web-resource-collection&gt;
  &lt;web-resource-name&gt;Nrt&lt;/web-resource-name&gt;
  &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/web-resource-collection&gt;
  &lt;auth-constraint&gt;
  &lt;role-name&gt;admin&lt;/role-name&gt;
  &lt;/auth-constraint&gt;
  &lt;/security-constraint&gt;
  &lt;login-config&gt;
  &lt;auth-method&gt;BASIC&lt;/auth-method&gt;
  &lt;realm-name&gt;Home&lt;/realm-name&gt;
  &lt;/login-config&gt;
  </code></pre>
  <p>and a server.xml with the following content</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;Realm className=&quot;org.apache.catalina.realm.JNDIRealm&quot;
               connectionURL=&quot;ldap://192.168.75.146:389&quot;
               userPattern=&quot;uid={0},ou=people,dc=localhost,dc=localdomain&quot;
               roleBase=&quot;cn=admin,ou=group,dc=localhost,dc=localdomain&quot;
               roleName=&quot;cn&quot;
               roleSearch=&quot;memberUid={1}&quot;
               debug=&quot;99&quot;/&gt;
  </code></pre>
  <p>I have tried to find documentation around the net, but I'm simply stuck. So far, I've managed to access it without LDAP users, or log in with LDAP users and not access the files.</p>
  <p>Any help would be greatly appreciated.</p>