public boolean isGroupDN(LdapName dn) {
        Log.debug("LdapManager: Trying to check if DN is a group. DN: {}, Base DN: {} ...", dn, baseDN);

        // is it a sub DN of the base DN?
        if (!dn.startsWith(baseDN)
            && (alternateBaseDN == null || !dn.startsWith(alternateBaseDN))) {
            if (Log.isDebugEnabled()) {
                Log.debug("LdapManager: DN ({}) does not fit to baseDN ({},{})", dn, baseDN, alternateBaseDN);
            }
            return false;
        }

        DirContext ctx = null;
        try {
            Log.debug("LdapManager: Starting LDAP search to check group DN: {}", dn);
            // Search for the group in the node with the given DN.
            // should return the group object itself if is matches the group filter
            ctx = getContext(dn);
            // only search the object itself.
            SearchControls constraints = new SearchControls();
            constraints.setSearchScope(SearchControls.OBJECT_SCOPE);
            constraints.setReturningAttributes(new String[]{});
            String filter = MessageFormat.format(getGroupSearchFilter(), "*");
            NamingEnumeration<SearchResult> answer = ctx.search("", filter, constraints);

            Log.debug("LdapManager: ... group check search finished for DN: {}", dn);

            boolean result = (answer != null && answer.hasMoreElements());

            if (answer != null) {
                answer.close();
            }
            Log.debug("LdapManager: DN is group: {}? {}!", dn, result);
            return result;
        }
        catch (final NameNotFoundException e) {
            Log.info("LdapManager: Given DN not found (while checking if DN is a group)! {}", dn);
            return false;
        }
        catch (final NamingException e) {
            Log.error("LdapManager: Exception thrown while checking if DN is a group {}", dn, e);
            return false;
        }
        finally {
            try {
                if (ctx != null)
                    ctx.close();
            }
            catch (Exception ex) {
                Log.debug("An exception occurred while trying to close a LDAP context after trying to verify that DN '{}' is a group.", dn, ex);
            }
        }
    }
Check if the given DN matches the group search filter

@param dn the absolute DN of the node to check
@return true if the given DN is matching the group filter. false oterwise.
@throws NamingException if the search for the dn fails.
xmppserver/src/main/java/org/jivesoftware/openfire/ldap/LdapManager.java