title: How can I call Active Directory using Windows Authentication without prompting for username/password?
body: <p>You can see an example of accessing LDAP using the <code>InitialLdapContext</code> class in Java in the following posts:</p>
  
  <p><a href="http://forums.sun.com/thread.jspa?threadID=603815" rel="nofollow noreferrer">http://forums.sun.com/thread.jspa?threadID=603815</a></p>
  
  <p><a href="http://forums.devshed.com/ldap-programming-76/active-directory-services-using-java-api-89586.html" rel="nofollow noreferrer">http://forums.devshed.com/ldap-programming-76/active-directory-services-using-java-api-89586.html</a></p>
  
  <p>This requires a login and password to be passed in (even though the service account or user running the java process has already logged in to be able to run).</p>
  
  <p>As the user or service account is already logged in - they can already run active directory commands like the following without a user name or password:</p>
  
  <pre><code>dsquery user -samid "login" |dsget user -samid -email -display
  </code></pre>
  
  <p>So why does Java need the login password if this query is already available to Windows? Kosuke hints that it is not required in this blog post under conclusion:</p>
  
  <p><a href="https://community.oracle.com/blogs/kohsuke/2008/06/12/more-active-directory-integration-java" rel="nofollow noreferrer">https://community.oracle.com/blogs/kohsuke/2008/06/12/more-active-directory-integration-java</a></p>
  
  <p>How can we call Active Directory in Java without:</p>
  
  <ul>
  <li>using a login or password (running under an account that is already logged in)?</li>
  <li>executing a command on the command line?</li>
  </ul>