From 5cc0b4ed2843ad093191f6dbe979a0afbe7c8619 Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Wed, 17 Apr 2013 12:35:46 +0200 Subject: add sss_ldap_encode_ndr_uint32 Converts uint32 to a string value that is suitable for octed string attributes. --- src/util/sss_ldap.c | 15 +++++++++++++++ src/util/sss_ldap.h | 2 ++ 2 files changed, 17 insertions(+) (limited to 'src/util') diff --git a/src/util/sss_ldap.c b/src/util/sss_ldap.c index f7834d940..dea38eaa9 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 7399c4d0a..e5c30eb21 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__ */ -- cgit