There was ever only one value, so it didn't cause problems yet.
struct dict_ldap_map_post_settings *post,
const char **error_r)
{
+ ARRAY_TYPE(const_string) parsed_attributes;
const char *value;
- p_array_init(&set->parsed_attributes, set->pool, 2);
+
+ p_array_init(&parsed_attributes, set->pool, 2);
array_foreach_elem(&post->values, value) {
struct var_expand_program *prog;
/* When we free program, this name would be invalid,
so dup it here. */
ldap_attr = p_strdup(set->pool, ldap_attr);
- array_push_back(&set->parsed_attributes, &ldap_attr);
+ array_push_back(&parsed_attributes, &ldap_attr);
}
var_expand_program_free(&prog);
}
+ array_append_zero(&parsed_attributes);
+ set->parsed_attributes = array_front(&parsed_attributes);
return 0;
}
/* parsed */
- ARRAY_TYPE(const_string) parsed_attributes;
+ const char *const *parsed_attributes;
/* attributes sorted by the position in parsed_pattern. */
ARRAY_TYPE(const_string) parsed_pattern_keys;
e_debug(op->event, "got dn %s",
ldap_entry_dn(entry));
- const char *attribute;
- array_foreach_elem(&op->map->parsed_attributes, attribute) {
+ for (unsigned int i = 0; op->map->parsed_attributes[i] != NULL; i++) {
+ const char *attribute = op->map->parsed_attributes[i];
const char *const *values = ldap_entry_get_attribute(entry, attribute);
bool no_attribute = values == NULL;
e_debug(op->event, "%s attribute %s",
input.scope = op->map->parsed_scope;
/* Guaranteed to be NULL-terminated by
dict_ldap_map_settings_postcheck() */
- input.attributes =
- array_is_empty(&op->map->parsed_attributes) ? NULL :
- array_front(&op->map->parsed_attributes);
+ input.attributes = op->map->parsed_attributes[0] == NULL ? NULL :
+ op->map->parsed_attributes;
ctx->pending++;
ldap_search_start(ctx->client, &input, ldap_dict_lookup_callback, op);
settings_free(pre);