title: Logged User on LDAP get all details
body: <p>I have done a connection to a LDAP server in Java using: </p>
  
  <pre><code>Hashtable&lt;String, String&gt; env = new Hashtable&lt;String, String&gt;();
  env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
  env.put(Context.PROVIDER_URL, "ldap://XXX");
  env.put(Context.SECURITY_AUTHENTICATION, "simple");
  env.put(Context.SECURITY_PRINCIPAL, "DOMAIN\\user.name"); 
  env.put(Context.SECURITY_CREDENTIALS, "password");
  DirContext ctx = new InitialDirContext(env);
  if(ctx != null){
      // get details : samaccount, mail, userprincipal, all fields from AD
  }
  </code></pre>
  
  <p>I am a newbie in all computer languages, but in PHP I can define a filter using
  a <code>samaccountname</code>(same as <code>user.name</code> in previous code) and that search returns
  an associative arrays of all details of that user. How can I do this in Java?
  Just using the <code>samaccountname</code>(user will enter just <code>user.name</code> value and his password), after bind is done ok and context is created
  get all details of him. </p>
  
  <p>Thanks in advance.</p>
  
  <p>(PS: I didnt find anything on google that can help).</p>