title: Get all attributes from Active Directory using Spring LdapTemplate
body: <p>I have a Spring Boot application that uses LDAP to authenticate the users. For the users, I am mapping the attributes from AD and populating the values like the user's first name, last name, department, email, telephone, and also the image. However, I am unable to get the employee number from the attributes.
  When I check the attributes using the tool <a href="https://docs.microsoft.com/en-us/sysinternals/downloads/adexplorer" rel="nofollow noreferrer">Active Directory explorer</a>, I am able to see 88 attributes per entry. However, when I print every attribute from the context using this code, </p>
  
  <pre><code>@Bean
  public UserDetailsContextMapper userDetailsContextMapper() {
      return new LdapUserDetailsMapper() {
          @Override
          public UserDetails mapUserFromContext(DirContextOperations ctx, String username, Collection&lt;? extends GrantedAuthority&gt; authorities) {
  
              String email = ctx.getStringAttribute("mail");
              String department = ctx.getStringAttribute("department");
              String empNumber = ctx.getStringAttribute("employeeNumber");
              System.out.println(empNumber); // this prints null
  
              System.out.println(ctx.attributeExists("employeeNumber")); // this prints false
  
  
  
              byte[] value= (byte[])ctx.getObjectAttribute("thumbNailPhoto");
              BASE64Encoder base64Encoder = new BASE64Encoder();
              StringBuilder imageString = new StringBuilder();
              imageString.append("data:image/jpg;base64,");
              imageString.append(base64Encoder.encode(value));
              String image = imageString.toString();
  
              Attributes attributes = ctx.getAttributes();
  
              NamingEnumeration&lt;? extends Attribute&gt; namingEnumeration = attributes.getAll();
  
              try {
                  while(namingEnumeration.hasMore()){ 
                   /*this loop prints 75 attributes but employeeNumber attribute is missing along with some other attributes*/
                      Attribute attribute = namingEnumeration.next();
                      System.out.println(attribute); 
                  }
              } catch (NamingException e) {
                  e.printStackTrace();
              }
  
              CustomUserDetails userDetails = (CustomUserDetails)userService.loadUserByUsername(username);
              userDetails.setImage(image);
              userDetails.setEmail(email);
              userDetails.setDepartment(department);
  
              return userDetails;
          }
      };
  }
  </code></pre>
  
  <p>only 75 attributes are printed. Why is it that some of the attributes are not retrieved? how can i access those attributes?</p>