From 64ddff90c7fcc02ccb06824ac93af7d5f361a88f Mon Sep 17 00:00:00 2001 From: Jan Zeleny Date: Wed, 23 May 2012 04:21:35 -0400 Subject: Add support for filtering atributes This patch adds support for filtering attributes when constructing attribute list from a map for LDAP query. --- src/providers/ldap/sdap.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/providers/ldap/sdap.c') diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c index 01ba418a..cb02f4a5 100644 --- a/src/providers/ldap/sdap.c +++ b/src/providers/ldap/sdap.c @@ -1019,10 +1019,28 @@ void sdap_steal_server_opts(struct sdap_id_ctx *id_ctx, id_ctx->srv_opts = talloc_move(id_ctx, srv_opts); } +static bool attr_is_filtered(const char *attr, const char **filter) +{ + int i; + + if (filter) { + i = 0; + while (filter[i]) { + if (filter[i] == attr || + strcasecmp(filter[i], attr) == 0) { + return true; + } + i++; + } + } + + return false; +} int build_attrs_from_map(TALLOC_CTX *memctx, struct sdap_attr_map *map, size_t size, + const char **filter, const char ***_attrs, size_t *attr_count) { @@ -1045,7 +1063,7 @@ int build_attrs_from_map(TALLOC_CTX *memctx, /* add the others */ for (i = j = 1; i < size; i++) { - if (map[i].name) { + if (map[i].name && !attr_is_filtered(map[i].name, filter)) { attrs[j] = map[i].name; j++; } -- cgit