From 34e810076df8720a145f5a619ed648c384898563 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 28 Apr 2006 14:44:43 +0000 Subject: r15305: Let winbind search by sid directly (or in windows terms: "bind to a sid"); works in all AD versions I tested. Also add "net ads sid" search tool. Guenther (This used to be commit 5557ada6943b817d28a5471c613c7291febe2ad5) --- source3/lib/util_sid.c | 18 ++++++++++++++++++ source3/lib/util_str.c | 18 +++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c index 0710337637..307f3e3415 100644 --- a/source3/lib/util_sid.c +++ b/source3/lib/util_sid.c @@ -528,6 +528,24 @@ BOOL non_mappable_sid(DOM_SID *sid) *****************************************************************/ char *sid_binstring(const DOM_SID *sid) +{ + char *buf, *s; + int len = sid_size(sid); + buf = SMB_MALLOC(len); + if (!buf) + return NULL; + sid_linearize(buf, len, sid); + s = binary_string_rfc2254(buf, len); + free(buf); + return s; +} + +/***************************************************************** + Return the binary string representation of a DOM_SID. + Caller must free. +*****************************************************************/ + +char *sid_binstring_hex(const DOM_SID *sid) { char *buf, *s; int len = sid_size(sid); diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 439cbea6d9..df84fa90a5 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -1566,7 +1566,7 @@ void strupper_m(char *s) Caller must free. **/ -char *binary_string(char *buf, int len) +char *binary_string_rfc2254(char *buf, int len) { char *s; int i, j; @@ -1584,6 +1584,22 @@ char *binary_string(char *buf, int len) return s; } +char *binary_string(char *buf, int len) +{ + char *s; + int i, j; + const char *hex = "0123456789ABCDEF"; + s = SMB_MALLOC(len * 2 + 1); + if (!s) + return NULL; + for (j=i=0;i> 4]; + s[j+1] = hex[((unsigned char)buf[i]) & 0xF]; + j += 2; + } + s[j] = 0; + return s; +} /** Just a typesafety wrapper for snprintf into a pstring. **/ -- cgit