title: Authenticating users programmatically
body: <p>I have a servlet that mimics the Domino login form.  Authentication is done against LDAP through Directory Assistance.</p>
  
  <p>The server first checks if the password is expired.  If it hasn't expired then it goes on to authenticate the user.  The authenticate process then starts from the servlet, by sending HTML that mimics the default login page for Domino, the code is below.  It is not very secure.</p>
  
  <p>Is there a Domino method in Java that I can call to authenticate the user from my servlet?  </p>
  
  <p>I was thinking about doing a POST but not sure if that would be as secure.</p>
  
  <p>Any ideas?</p>
  
  <pre><code>   private void logUserIntoNotes(HttpServletResponse response) throws IOException
     {
      String action = "/names.nsf?Login";
  
      System.out.println("Action=" + action);
      System.out.println("Username=" + username);
      //System.out.println("Password=" + password);
      System.out.println("RedirectTo=" + redirectTo);
  
  
      response.setContentType("text/html");
  
      ServletOutputStream out = response.getOutputStream();
      out.println("&lt;html&gt;&lt;head&gt;&lt;title&gt;Login Page&lt;/title&gt;&lt;/head&gt;&lt;body&gt;");
      out.println("Logging in. Please wait ...");
      out.println("&lt;form method=\"post\" name=\"login\" action=\"" + action + "\"&gt;");
      out.println("&lt;input type=\"hidden\" name=\"Username\" value=\"" + username + "\"&gt;");
      out.println("&lt;input type=\"hidden\" name=\"Password\" value=\"" + password + "\"&gt;");
      out.println("&lt;input type=\"hidden\" name=\"RedirectTo\" value=\"" + redirectTo + "\"&gt;");
      out.println("&lt;/form&gt;");
      out.println("&lt;SCRIPT LANGUAGE=\"JavaScript\"&gt; document.forms[\"login\"].submit(); &lt;/SCRIPT&gt;");
      out.println("&lt;/body&gt;&lt;/html&gt;");
  }
  </code></pre>