summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-12-05 04:44:34 +0000
committerAndrew Tridgell <tridge@samba.org>2001-12-05 04:44:34 +0000
commit31d6d049b30e364e062f108d6f9221bbdc2ebec5 (patch)
treecfac45c82e10f15b166dc7b482716ca7eae913c1
parent2b2155beaef17a13c0e867c3dcfe8c323e84a9a3 (diff)
downloadsamba-31d6d049b30e364e062f108d6f9221bbdc2ebec5.tar.gz
added functions that convert a ads binary blob to a string (for
searching on SID)
-rw-r--r--source/libads/ldap.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/source/libads/ldap.c b/source/libads/ldap.c
index 50583146c08..34ca2ad04db 100644
--- a/source/libads/ldap.c
+++ b/source/libads/ldap.c
@@ -376,6 +376,45 @@ NTSTATUS ads_set_machine_password(ADS_STRUCT *ads,
return ret;
}
+
+/*
+ return a RFC2254 binary string representation of a buffer
+ used in filters
+ caller must free
+*/
+char *ads_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;
+}
+
+/*
+ return the binary string representation of a DOM_SID
+ caller must free
+*/
+char *ads_sid_binstring(DOM_SID *sid)
+{
+ char *buf, *s;
+ int len = sid_size(sid);
+ buf = malloc(len);
+ if (!buf) return NULL;
+ sid_linearize(buf, len, sid);
+ s = ads_binary_string(buf, len);
+ free(buf);
+ return s;
+}
+
/*
pull the first entry from a ADS result
*/