summaryrefslogtreecommitdiffstats
path: root/src/providers
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2011-06-06 22:26:28 -0400
committerStephen Gallagher <sgallagh@redhat.com>2011-07-08 15:12:24 -0400
commit31442edcf62c284d5d983bda48e51ae55b70ebdf (patch)
tree4aa2287aad43a30c5ac72d0786782f81aa71d8e9 /src/providers
parent5dcaf08d0ae528318d2fb7dd9a6d37abbface6b8 (diff)
downloadsssd-31442edcf62c284d5d983bda48e51ae55b70ebdf.tar.gz
sssd-31442edcf62c284d5d983bda48e51ae55b70ebdf.tar.xz
sssd-31442edcf62c284d5d983bda48e51ae55b70ebdf.zip
Add helper function msgs2attrs_array
This function converts a list of ldb_messages into a list of sysdb_attrs.
Diffstat (limited to 'src/providers')
-rw-r--r--src/providers/ldap/ldap_common.c29
-rw-r--r--src/providers/ldap/ldap_common.h4
2 files changed, 33 insertions, 0 deletions
diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c
index 2ffa878d8..5b75cf285 100644
--- a/src/providers/ldap/ldap_common.c
+++ b/src/providers/ldap/ldap_common.c
@@ -1062,3 +1062,32 @@ char *sdap_get_id_specific_filter(TALLOC_CTX *mem_ctx,
}
return filter; /* NULL or not */
}
+
+errno_t msgs2attrs_array(TALLOC_CTX *mem_ctx, size_t count,
+ struct ldb_message **msgs,
+ struct sysdb_attrs ***attrs)
+{
+ int i;
+ struct sysdb_attrs **a;
+
+ a = talloc_array(mem_ctx, struct sysdb_attrs *, count);
+ if (a == NULL) {
+ DEBUG(1, ("talloc_array failed.\n"));
+ return ENOMEM;
+ }
+
+ for (i = 0; i < count; i++) {
+ a[i] = talloc(a, struct sysdb_attrs);
+ if (a[i] == NULL) {
+ DEBUG(1, ("talloc_array failed.\n"));
+ talloc_free(a);
+ return ENOMEM;
+ }
+ a[i]->num = msgs[i]->num_elements;
+ a[i]->a = talloc_steal(a[i], msgs[i]->elements);
+ }
+
+ *attrs = a;
+
+ return EOK;
+}
diff --git a/src/providers/ldap/ldap_common.h b/src/providers/ldap/ldap_common.h
index f4746805e..2d4b17556 100644
--- a/src/providers/ldap/ldap_common.h
+++ b/src/providers/ldap/ldap_common.h
@@ -166,4 +166,8 @@ char *sdap_get_id_specific_filter(TALLOC_CTX *mem_ctx,
char *base_filter,
char *extra_filter);
+errno_t msgs2attrs_array(TALLOC_CTX *mem_ctx, size_t count,
+ struct ldb_message **msgs,
+ struct sysdb_attrs ***attrs);
+
#endif /* _LDAP_COMMON_H_ */