summaryrefslogtreecommitdiff
path: root/source3/lib/util_str.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-12-10 00:39:01 +0000
committerAndrew Tridgell <tridge@samba.org>2001-12-10 00:39:01 +0000
commite051c2c430f706835f250b10cc63e5621054b5ec (patch)
treee35e8844027bdacd71b926cf448e25ea5d21e28c /source3/lib/util_str.c
parent4ad81e7714bac620ae8c5a3a341548523c7ceada (diff)
downloadsamba-e051c2c430f706835f250b10cc63e5621054b5ec.tar.gz
samba-e051c2c430f706835f250b10cc63e5621054b5ec.tar.bz2
samba-e051c2c430f706835f250b10cc63e5621054b5ec.zip
make sid_binstring available without HAVE_ADS
(This used to be commit 4a6d29768665f71b72cf48ee34ee9a9c451232f6)
Diffstat (limited to 'source3/lib/util_str.c')
-rw-r--r--source3/lib/util_str.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index d7e6fa0781..2205f5cf0d 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -914,3 +914,26 @@ void strupper_m(char *s)
* as source string even in multibyte encoding. (VIV) */
unix_strupper(s,strlen(s)+1,s,strlen(s)+1);
}
+
+/*
+ return a RFC2254 binary string representation of a buffer
+ used in LDAP filters
+ caller must free
+*/
+char *binary_string(char *buf, int len)
+{
+ char *s;
+ int i, j;
+ const char *hex = "0123456789ABCDEF";
+ s = malloc(len * 3 + 1);
+ if (!s) return NULL;
+ for (j=i=0;i<len;i++) {
+ s[j] = '\\';
+ s[j+1] = hex[((unsigned char)buf[i]) >> 4];
+ s[j+2] = hex[((unsigned char)buf[i]) & 0xF];
+ j += 3;
+ }
+ s[j] = 0;
+ return s;
+}
+