title: How do I get all the memberOf Attribute assign to a particular user in LDAP
body: <p>I have created an application which uses LDAP for authentication. I need to find out all the group name in which the User is assign to. Is there any way to find out that. I have written code but somehow it return only one group name that to randomly.</p>
  <p>Below is my code to get all memberOf the users.</p>
  <pre><code>private class UserAttributesMapper implements AttributesMapper {
          @Override
          public Object mapFromAttributes(Attributes attributes) throws NamingException {
              LdapUser user = new LdapUser();
              user.setCn((String)attributes.get(&quot;cn&quot;).get());
              user.setMemberOf((String)attributes.get(&quot;memberOf&quot;).get());
              
              /*String member = (String)attributes.get(&quot;memberOf&quot;).get();
              int length = attributes.get(&quot;memberOf&quot;).size();
              if(member != null){
                  for(int i = 0;i&lt;= length; i++){
                      user.setMemberOf(member);
                  }
              }*/
              
              
              //user.setMemberOf(attributes.get(&quot;memberOf&quot;).getID());
              user.setsAMAccountName((String)attributes.get(&quot;sAMAccountName&quot;).get());
              return user;
          }
      }
  </code></pre>
  <p>This class is used to set attribute and return attribute for the user.</p>