title: Ldap get users in a distribution list
body: <p>I'm trying to get all the users of a DL using below code.The code is working as expected. However, I'm not able to get AD usernames for some users. Ex. First row of the o/p has username rkama but not the second row. Is this LDAP data issue or is there a different way to get user name/email address in a DL.</p>
  
  <p>O/p
  Entry is : CN=Ay\,Ram(rkama),OU=Site-SJN,OU=Accounts_User,DC=corp,DC=XXX,DC=com
  Entry is : CN=Wang\,Peter(),OU=Site-SJN,OU=Accounts_User,DC=corp,DC=XXX,DC=com</p>
  
  <pre><code>public ArrayList&lt;String&gt; getAllDLs(String dlname) throws NamingException {
      ArrayList&lt;String&gt; dls = new ArrayList&lt;String&gt;();
      String attributes[] = { "member", "displayName" };
      createDLContext();
      SearchControls ctrl = new SearchControls();
      ctrl.setSearchScope(SearchControls.SUBTREE_SCOPE);
      ctrl.setReturningAttributes(attributes);
  
      String search = "(&amp;(objectClass=group)((sAMAccountName="+dlname+"*)))";
      NamingEnumeration enumeration = dlContext.search("", search, ctrl);
  
      while (enumeration.hasMoreElements()) {
          SearchResult result = (SearchResult) enumeration.next();
  
          System.out.println("Found match &amp; result is : " + result);
          NamingEnumeration&lt;?&gt; n2 = result.getAttributes().get("member").getAll(); 
  
          while (n2 != null &amp;&amp; n2.hasMore()) {
              String dlList = (String) n2.next();
              System.out.println("Entry is : " + dlList);
  
          }
      }
      dlContext.close();      
      return dls;
  }
  </code></pre>