Get the groups that contain the specified DN as its member.

@param dn
@return
@throws WIMException
9631
private List<String> getGroups(String dn) throws WIMException {
        List<String> grpList = new ArrayList<String>();
        String filter = iLdapConfigMgr.getGroupMemberFilter(dn);
        String[] searchBases = iLdapConfigMgr.getGroupSearchBases();
        for (int i = 0; i < searchBases.length; i++) {
            String searchBase = searchBases[i];
            NamingEnumeration<SearchResult> nenu = iLdapConn.search(searchBase, filter, SearchControls.SUBTREE_SCOPE,
                                                                    LDAP_ATTR_OBJECTCLASS_ARRAY);
            while (nenu.hasMoreElements()) {
                SearchResult thisEntry = nenu.nextElement();
                if (thisEntry == null) {
                    continue;
                }
                String entryName = thisEntry.getName();
                if (entryName == null || entryName.trim().length() == 0) {
                    continue;
                }
                grpList.add(LdapHelper.prepareDN(entryName, searchBase));
            }
        }
        return grpList;
    }
1276667
public java.util.List<String> getGroupIds() {
        if (groupIds == null) {
            groupIds = new com.amazonaws.internal.SdkInternalList<String>();
        }
        return groupIds;
    }
100498
private Collection<Group> findGroups(Session session, Group parent, boolean recursive) throws Exception
   {
      List<Group> groups = new ArrayList<Group>();
      String parentId = parent == null ? "" : parent.getId();

      NodeIterator childNodes = utils.getGroupNode(session, parentId).getNodes();

      while (childNodes.hasNext())
      {
         Node groupNode = childNodes.nextNode();
         if (!groupNode.getName().startsWith(JCROrganizationServiceImpl.JOS_MEMBERSHIP))
         {
            Group group = readGroup(groupNode);
            groups.add(group);

            if (recursive)
            {
               groups.addAll(findGroups(session, group, recursive));
            }
         }
      }

      return groups;
   }
1071240
def groups(self):
        
        group_list = []
        all_groups = self.get('memberof')
        for group_dn in all_groups:
            if self.__ldap_group_ou__ in group_dn:
                group_list.append(group_dn)

        return group_list
523864
@Override
    public Iterator findMemberGroups(IEntityGroup eg) throws GroupsException {
        Map groups = new HashMap();
        IEntityGroup group = null;
        for (Iterator itr = findLocalMemberGroups(eg); itr.hasNext(); ) {
            group = (IEntityGroup) itr.next();
            groups.put(group.getKey(), group);
        }

        String[] memberGroupKeys = getGroupStore().findMemberGroupKeys(eg);
        for (int i = 0; i < memberGroupKeys.length; i++) {
            if (!groups.containsKey(memberGroupKeys[i])) {
                group = GroupService.findGroup(memberGroupKeys[i]);
                if (group != null) {
                    groups.put(group.getKey(), group);
                }
            }
        }
        return groups.values().iterator();
    }
1275526
public Entry lookup(Dn dn) throws NoSuchNodeException, MissingParentException {
        existsCheck(dn);
        try {
            return connection.lookup(dn);
        } catch (LdapException e) {
            throw new LdapDaoException(e);
        }
    }
481267
@Override
    public Set<Entity> getGroupsForMember(String memberName) {
        Set<Entity> groups = new HashSet<Entity>();
        if (StringUtils.isNotEmpty(memberName)) {
            EntityIdentifier[] identifiers =
                    GroupService.searchForEntities(
                            memberName,
                            GroupService.SearchMethod.DISCRETE,
                            EntityEnum.PERSON.getClazz());
            for (EntityIdentifier entityIdentifier : identifiers) {
                if (entityIdentifier.getType().equals(EntityEnum.PERSON.getClazz())) {
                    IGroupMember groupMember = GroupService.getGroupMember(entityIdentifier);
                    if (memberName.equalsIgnoreCase(groupMember.getKey())) {
                        Iterator it = GroupService.findParentGroups(groupMember);
                        while (it.hasNext()) {
                            IEntityGroup g = (IEntityGroup) it.next();
                            Entity e =
                                    EntityFactory.createEntity(
                                            g, EntityEnum.getEntityEnum(g.getLeafType(), true));
                            groups.add(e);
                        }
                        return groups;
                    }
                }
            }
        }
        return groups;
    }
531700
public void getGroupsForUser(List<String> grpMbrshipAttrs, int countLimit) throws Exception {
        throw new WIMApplicationException(WIMMessageKey.METHOD_NOT_IMPLEMENTED, Tr.formatMessage(tc, WIMMessageKey.METHOD_NOT_IMPLEMENTED));
    }
250714
@Override
	public List<CommerceWishList> findByGroupId(long groupId) {
		return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
	}
90507
GroupIds getGroupIds(Node groupNode) throws RepositoryException
   {
      String storagePath = getGroupStoragePath();
      String nodePath = groupNode.getPath();

      String groupId = nodePath.substring(storagePath.length());
      String parentId = groupId.substring(0, groupId.lastIndexOf("/"));

      return new GroupIds(groupId, parentId);
   }
1277061
def walk_ldap_members(groups, dn, seen = [])
      groups.each do |g|
        members = ldap_members(g)
        return true if members.include? dn
        next if seen.include? g
        seen << g
        member_groups = members.collect do |mg|
          dn_to_cn(mg) if (mg.include?('OU=Groups') || mg.include?('OU=Applications'))
        end
        member_groups.compact!
        return true if walk_ldap_members(member_groups, dn, seen)
      end
      return false
    end
921591
private function _list_group_members($dn, $entry, $attr, $count)
    {
        // Use the member attributes to return an array of member ldap objects
        // NOTE that the member attribute is supposed to contain a DN
        $group_members = array();
        if (empty($entry[$attr])) {
            return $group_members;
        }

        // read these attributes for all members
        $attrib = $count ? array('dn','objectClass') : $this->prop['list_attributes'];
        $attrib = array_merge($attrib, array_values($this->group_types));
        $attrib[] = 'memberURL';

        $filter = $this->prop['groups']['member_filter'] ?: '(objectclass=*)';

        for ($i=0; $i < $entry[$attr]['count']; $i++) {
            if (empty($entry[$attr][$i]))
                continue;

            $members = $this->ldap->read_entries($entry[$attr][$i], $filter, $attrib);
            if ($members == false) {
                $members = array();
            }

            // for nested groups, call recursively
            $nested_group_members = $this->list_group_members($entry[$attr][$i], $count, $members);

            unset($members['count']);
            $group_members = array_merge($group_members, array_filter($members), $nested_group_members);
        }

        return $group_members;
    }
1347330
public PagedList<NetworkWatcherInner> listByResourceGroup(String resourceGroupName) {
        PageImpl1<NetworkWatcherInner> page = new PageImpl1<>();
        page.setItems(listByResourceGroupWithServiceResponseAsync(resourceGroupName).toBlocking().single().body());
        page.setNextPageLink(null);
        return new PagedList<NetworkWatcherInner>(page) {
            @Override
            public Page<NetworkWatcherInner> nextPage(String nextPageLink) {
                return null;
            }
        };
    }
1074979
@Override
    public Set<Node> getGroupsForUser(Node user) {
        Set<Node> groups = new TreeSet<>();
        try {
            String query = "(& (objectClass=" + groupObjectClass + ") (" + groupMemberAttribut + "=" + ((LdapUser) user).getDn() + "))";
            SearchResult searchResult;
            Attributes attributes;
            SearchControls controls = new SearchControls();
            controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
            NamingEnumeration<SearchResult> results = ctx.search("", query, controls);
            queryCount++;
            Node group;
            while (results.hasMore()) {
                searchResult = results.next();
                attributes = searchResult.getAttributes();
                group = getGroup(getAttributeOrNa(attributes, groupIdentifyer));
                group.setDn(searchResult.getNameInNamespace());
                groups.add(group);
            }
        } catch (NamingException ex) {
            handleNamingException(user, ex);
        }
        return groups;
    }
910716
@Override
    public String[] findMemberGroupKeys(IEntityGroup group) throws GroupsException {
        Connection conn = null;
        Collection groupKeys = new ArrayList();
        String groupKey = null;

        try {
            conn = RDBMServices.getConnection();
            String sql = getFindMemberGroupKeysSql();
            PreparedStatement ps = conn.prepareStatement(sql);
            try {
                ps.setString(1, group.getLocalKey());
                if (LOG.isDebugEnabled())
                    LOG.debug(
                            "RDBMEntityGroupStore.findMemberGroupKeys(): "
                                    + ps
                                    + " ("
                                    + group.getLocalKey()
                                    + ")");
                ResultSet rs = ps.executeQuery();
                try {
                    while (rs.next()) {
                        groupKey = rs.getString(1) + groupNodeSeparator + rs.getString(2);
                        groupKeys.add(groupKey);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                ps.close();
            }
        } catch (Exception sqle) {
            LOG.error("RDBMEntityGroupStore.findMemberGroupKeys(): " + sqle);
            throw new GroupsException("Problem retrieving member group keys: " + sqle);
        } finally {
            RDBMServices.releaseConnection(conn);
        }

        return (String[]) groupKeys.toArray(new String[groupKeys.size()]);
    }
849149
private Membership findMembershipByUserGroupAndType(Session session, String userName, String groupId, String type)
      throws Exception
   {
      MembershipImpl membership = getFromCache(userName, groupId, type);
      if (membership != null)
      {
         return membership;
      }

      try
      {
         Node groupNode = utils.getGroupNode(session, groupId);

         Node refUserNode = groupNode.getNode(JCROrganizationServiceImpl.JOS_MEMBERSHIP).getNode(userName);
         Node refTypeNode =
            refUserNode.getNode(type.equals(MembershipTypeHandler.ANY_MEMBERSHIP_TYPE)
               ? JCROrganizationServiceImpl.JOS_MEMBERSHIP_TYPE_ANY : type);

         String id = utils.composeMembershipId(groupNode, refUserNode, refTypeNode);

         membership = new MembershipImpl();
         membership.setGroupId(groupId);
         membership.setUserName(userName);
         membership.setMembershipType(type);
         membership.setId(id);

         putInCache(membership);

         return membership;
      }
      catch (PathNotFoundException e)
      {
         return null;
      }
   }
714927
@Override
    public Iterator findMemberGroups(IEntityGroup group) throws GroupsException {
        Connection conn = null;
        Collection groups = new ArrayList();
        IEntityGroup eg = null;
        String serviceName = group.getServiceName().toString();
        String localKey = group.getLocalKey();

        try {
            conn = RDBMServices.getConnection();
            String sql = getFindMemberGroupsSql();
            PreparedStatement ps = conn.prepareStatement(sql);
            try {
                ps.setString(1, localKey);
                ps.setString(2, serviceName);
                if (LOG.isDebugEnabled())
                    LOG.debug(
                            "RDBMEntityGroupStore.findMemberGroups(): "
                                    + ps
                                    + " ("
                                    + localKey
                                    + ", "
                                    + serviceName
                                    + ")");
                ResultSet rs = ps.executeQuery();
                try {
                    while (rs.next()) {
                        eg = instanceFromResultSet(rs);
                        groups.add(eg);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                ps.close();
            }
        } catch (Exception sqle) {
            LOG.error("RDBMEntityGroupStore.findMemberGroups(): " + sqle);
            throw new GroupsException("Problem retrieving member groups: " + sqle);
        } finally {
            RDBMServices.releaseConnection(conn);
        }

        return groups.iterator();
    }