title: Retrieve Full name or Display name from LDAP server using AD and Apache shiro
body: <p>I'm trying to authenticate a set of credentials against an LDAP server and I was able to authenticate them successfully. Now am trying to get the full name or the display name of the user logged-in into the server. Am unable to get the same. Being new to LDAP concepts, am unable to figure out a way to get the full display name of the user. Can some please help me how to get the full display name of the user logged in. </p>
  
  <p>Below is the shiro.ini file am using:</p>
  
  <pre><code>[main]
  activeDirectoryRealm = 
  org.apache.shiro.realm.activedirectory.ActiveDirectoryRealm
  activeDirectoryRealm.systemUsername = adminusername
  activeDirectoryRealm.systemPassword = adminpswd
  activeDirectoryRealm.searchBase = "OU=User Accounts,DC=dmn,DC=net"
  activeDirectoryRealm.url = ldaps://localhost:389
  </code></pre>
  
  <p>My Java code is as below:</p>
  
  <pre><code>import org.apache.shiro.SecurityUtils;
  import org.apache.shiro.authc.*;
  import org.apache.shiro.config.IniSecurityManagerFactory;
  import org.apache.shiro.mgt.SecurityManager;
  import org.apache.shiro.subject.Subject;
  import org.apache.shiro.util.Factory;
  public class ExampleActiveDirectory {
  
  
  public static final String userName = "myusername";
  public static final String password = "mypassword";
  
  public static void main(String[] args)
  {
      //Factory&lt;SecurityManager&gt; factory = new IniSecurityManagerFactory("N:\\workspace\\LdapAuthentication\\src\\auth.ini");
      Factory&lt;SecurityManager&gt; factory = new IniSecurityManagerFactory("N:\\workspace\\LdapAuthentication\\src\\shiro.ini");
      SecurityManager securityManager = factory.getInstance();
      SecurityUtils.setSecurityManager( securityManager );
      System.out.println( "userName is  : " +userName);
      System.out.println( "password is  : " +password);
      UsernamePasswordToken token = new UsernamePasswordToken( userName,password );
      Subject currentUser = SecurityUtils.getSubject();
      try
      {
          //currentUser.login( token ) ;
          securityManager.login(currentUser,token).isAuthenticated();
          System.out.println( "We've authenticated! :)" );
      }
      catch ( AuthenticationException e )
      {
          System.out.println( "We did not authenticate :(" );
          e.printStackTrace();
      }
  
     }
  }
  </code></pre>