summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2013-04-17 12:35:46 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-05-02 16:48:12 +0200
commit5cc0b4ed2843ad093191f6dbe979a0afbe7c8619 (patch)
tree21ab14007d436fbc0ec9123e97a0703177ddd6e0
parent05c53cfcee72dcb9e6103de7877ede220369ccf4 (diff)
downloadsssd-5cc0b4ed2843ad093191f6dbe979a0afbe7c8619.tar.gz
sssd-5cc0b4ed2843ad093191f6dbe979a0afbe7c8619.tar.bz2
sssd-5cc0b4ed2843ad093191f6dbe979a0afbe7c8619.zip
add sss_ldap_encode_ndr_uint32
Converts uint32 to a string value that is suitable for octed string attributes.
-rw-r--r--src/util/sss_ldap.c15
-rw-r--r--src/util/sss_ldap.h2
2 files changed, 17 insertions, 0 deletions
diff --git a/src/util/sss_ldap.c b/src/util/sss_ldap.c
index f7834d94..dea38eaa 100644
--- a/src/util/sss_ldap.c
+++ b/src/util/sss_ldap.c
@@ -587,3 +587,18 @@ done:
talloc_free(filter);
return ret;
}
+
+char *sss_ldap_encode_ndr_uint32(TALLOC_CTX *mem_ctx, uint32_t flags)
+{
+ char hex[9]; /* 4 bytes in hex + terminating zero */
+ errno_t ret;
+
+ ret = snprintf(hex, 9, "%08x", flags);
+ if (ret != 8) {
+ return NULL;
+ }
+
+ return talloc_asprintf(mem_ctx, "\\%c%c\\%c%c\\%c%c\\%c%c",
+ hex[6], hex[7], hex[4], hex[5],
+ hex[2], hex[3], hex[0], hex[1]);
+}
diff --git a/src/util/sss_ldap.h b/src/util/sss_ldap.h
index 7399c4d0..e5c30eb2 100644
--- a/src/util/sss_ldap.h
+++ b/src/util/sss_ldap.h
@@ -74,4 +74,6 @@ bool sss_ldap_dn_in_search_bases(TALLOC_CTX *mem_ctx,
struct sdap_search_base **search_bases,
char **_filter);
+char *sss_ldap_encode_ndr_uint32(TALLOC_CTX *mem_ctx, uint32_t flags);
+
#endif /* __SSS_LDAP_H__ */