def all_ldap_groups(username)
      return [] if service.nil?
      results = service.search(base: group_tree,
                   filter: Net::LDAP::Filter.eq('objectcategory', 'group') &
                       Net::LDAP::Filter.ex('member:1.2.840.113556.1.4.1941',
                                            "CN=#{Net::LDAP::Filter.escape(username)},#{account_tree}"),
                   attributes: ['cn'])
      if results.nil?
        []
      else
        results.collect do |entry|
          entry[:cn].first
        end
      end
    end
def all_ldap_groups(username)
      return [] if service.nil?
      results = service.search(base: group_tree,
                   filter: Net::LDAP::Filter.eq('objectcategory', 'group') &
                       Net::LDAP::Filter.ex('member:1.2.840.113556.1.4.1941',
                                            "CN=#{Net::LDAP::Filter.escape(username)},#{account_tree}"),
                   attributes: ['cn'])
      if results.nil?
        []
      else
        results.collect do |entry|
          entry[:cn].first
        end
      end
    end
Lists all groups that a user belongs to.
 Warning: Utilizes server-side recursive search but may be slower than walking the tree client-side.
 @param [string] username the user to search by