summaryrefslogtreecommitdiffstats
path: root/src/providers/ldap/sdap.c
diff options
context:
space:
mode:
authorJan Zeleny <jzeleny@redhat.com>2012-05-23 04:21:35 -0400
committerStephen Gallagher <sgallagh@redhat.com>2012-05-31 15:46:27 -0400
commit64ddff90c7fcc02ccb06824ac93af7d5f361a88f (patch)
tree70f12aa095d575826844f26278c2056ce8df0cf5 /src/providers/ldap/sdap.c
parent3111c28041b732b98a7fb39ef6232257d086d670 (diff)
downloadsssd-64ddff90c7fcc02ccb06824ac93af7d5f361a88f.tar.gz
sssd-64ddff90c7fcc02ccb06824ac93af7d5f361a88f.tar.xz
sssd-64ddff90c7fcc02ccb06824ac93af7d5f361a88f.zip
Add support for filtering atributes
This patch adds support for filtering attributes when constructing attribute list from a map for LDAP query.
Diffstat (limited to 'src/providers/ldap/sdap.c')
-rw-r--r--src/providers/ldap/sdap.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c
index 01ba418a6..cb02f4a5b 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++;
}