title: Authenticate credentials with LDAP for specific requests
body: <p>I have a web application that I deploy using JBoss 5.2. In order for a user to use the application, he/she must authenticate with an LDAP server (using simple authentication) with a username and password. This is all done through setting up the <code>login-config.xml</code> for JBoss and providing a <code>&lt;login-module&gt;</code> with our implementation.</p>
  
  <p>The problem comes in here: After having logged in, I have a scenario that requires the user to provide a username &amp; password when a particular action is performed (which I will also authenticate with the LDAP server). I want to be able to reuse the same mechanism that I use for authenticating the user into the web application.</p>
  
  <p>My form to log in to the application posts to <code>j_security_check</code> so in accordance with this, I was trying to send a request to <code>j_security_check</code> but JBOSS returns a 404. From reading around a bit, I've gathered <code>j_security_check</code> cannot be accessed by any arbitrary request and must be in response to a challenged request to a secured resource.</p>
  
  <p>So then, how can I authenticate the second set of credentials the user has provided with the same LDAP server? </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>To clarify, the question is how to send the user's credential inputs to the LDAP server for authentication. Grabbing the input from the user, etc. is all done. All that is left is to take this input and send it to the LDAP server and get the response (which is where I am stuck). </p>
  
  <p>If it helps to mention, the login to the web application uses a custom class that extends UsernamePasswordLoginModule.</p>