nodes: 0, module; 1, function_definition; 2, function_name:search_directory; 3, parameters; 4, block; 5, identifier:self; 6, dictionary_splat_pattern; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, return_statement; 13, identifier:kwargs; 14, comment:"""
          SearchAccount is deprecated, using SearchDirectory
  
          :param query: Query string - should be an LDAP-style filter
          string (RFC 2254)
          :param limit: The maximum number of accounts to return
          (0 is default and means all)
          :param offset: The starting offset (0, 25, etc)
          :param domain: The domain name to limit the search to
          :param applyCos: applyCos - Flag whether or not to apply the COS
          policy to account. Specify 0 (false) if only requesting attrs that
          aren't inherited from COS
          :param applyConfig: whether or not to apply the global config attrs to
          account. specify 0 (false) if only requesting attrs that aren't
          inherited from global config
          :param sortBy: Name of attribute to sort on. Default is the account
          name.
          :param types: Comma-separated list of types to return. Legal values
          are: accounts|distributionlists|aliases|resources|domains|coses
          (default is accounts)
          :param sortAscending: Whether to sort in ascending order. Default is
          1 (true)
          :param countOnly: Whether response should be count only. Default is
          0 (false)
          :param attrs: Comma-seperated list of attrs to return ("displayName",
          "zimbraId", "zimbraAccountStatus")
          :return: dict of list of "account" "alias" "dl" "calresource" "domain"
          "cos"
          """; 15, assignment; 16, assignment; 17, assignment; 18, pattern_list; 19, call; 20, block; 21, identifier:result; 22, identifier:search_response; 23, call; 24, identifier:result; 25, dictionary; 26, identifier:items; 27, dictionary; 28, identifier:obj_type; 29, identifier:func; 30, attribute; 31, argument_list; 32, if_statement; 33, attribute; 34, argument_list; 35, pair; 36, pair; 37, pair; 38, pair; 39, pair; 40, comment:# "alias": TODO,; 41, identifier:items; 42, identifier:items; 43, comparison_operator:obj_type in search_response; 44, block; 45, identifier:self; 46, identifier:request; 47, string; 48, identifier:kwargs; 49, string:"account"; 50, attribute; 51, string:"domain"; 52, attribute; 53, string:"dl"; 54, attribute; 55, string:"cos"; 56, attribute; 57, string:"calresource"; 58, attribute; 59, identifier:obj_type; 60, identifier:search_response; 61, if_statement; 62, string_content:SearchDirectory; 63, attribute; 64, identifier:from_dict; 65, attribute; 66, identifier:from_dict; 67, attribute; 68, identifier:from_dict; 69, attribute; 70, identifier:from_dict; 71, attribute; 72, identifier:from_dict; 73, call; 74, block; 75, else_clause; 76, identifier:zobjects; 77, identifier:Account; 78, identifier:zobjects; 79, identifier:Domain; 80, identifier:zobjects; 81, identifier:DistributionList; 82, identifier:zobjects; 83, identifier:COS; 84, identifier:zobjects; 85, identifier:CalendarResource; 86, identifier:isinstance; 87, argument_list; 88, expression_statement; 89, block; 90, subscript; 91, identifier:list; 92, assignment; 93, expression_statement; 94, identifier:search_response; 95, identifier:obj_type; 96, subscript; 97, list_comprehension; 98, assignment; 99, identifier:result; 100, identifier:obj_type; 101, call; 102, for_in_clause; 103, subscript; 104, call; 105, identifier:func; 106, argument_list; 107, identifier:v; 108, subscript; 109, identifier:result; 110, identifier:obj_type; 111, identifier:func; 112, argument_list; 113, identifier:v; 114, identifier:search_response; 115, identifier:obj_type; 116, subscript; 117, identifier:search_response; 118, identifier:obj_type
code: def search_directory(self, **kwargs):
          """
          SearchAccount is deprecated, using SearchDirectory
  
          :param query: Query string - should be an LDAP-style filter
          string (RFC 2254)
          :param limit: The maximum number of accounts to return
          (0 is default and means all)
          :param offset: The starting offset (0, 25, etc)
          :param domain: The domain name to limit the search to
          :param applyCos: applyCos - Flag whether or not to apply the COS
          policy to account. Specify 0 (false) if only requesting attrs that
          aren't inherited from COS
          :param applyConfig: whether or not to apply the global config attrs to
          account. specify 0 (false) if only requesting attrs that aren't
          inherited from global config
          :param sortBy: Name of attribute to sort on. Default is the account
          name.
          :param types: Comma-separated list of types to return. Legal values
          are: accounts|distributionlists|aliases|resources|domains|coses
          (default is accounts)
          :param sortAscending: Whether to sort in ascending order. Default is
          1 (true)
          :param countOnly: Whether response should be count only. Default is
          0 (false)
          :param attrs: Comma-seperated list of attrs to return ("displayName",
          "zimbraId", "zimbraAccountStatus")
          :return: dict of list of "account" "alias" "dl" "calresource" "domain"
          "cos"
          """
  
          search_response = self.request('SearchDirectory', kwargs)
  
          result = {}
          items = {
              "account": zobjects.Account.from_dict,
              "domain": zobjects.Domain.from_dict,
              "dl": zobjects.DistributionList.from_dict,
              "cos": zobjects.COS.from_dict,
              "calresource": zobjects.CalendarResource.from_dict
              # "alias": TODO,
          }
  
          for obj_type, func in items.items():
              if obj_type in search_response:
                  if isinstance(search_response[obj_type], list):
                      result[obj_type] = [
                          func(v) for v in search_response[obj_type]]
                  else:
                      result[obj_type] = func(search_response[obj_type])
          return result