From: Günther Deschner Date: Fri, 1 Aug 2008 13:15:05 +0000 (+0200) Subject: netapi: add ConvertStringSidToSid(). X-Git-Tag: samba-3.3.0pre1~248 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=36f1e45e4ec295115f1ba39ec7ad3690a96dac3e;p=thirdparty%2Fsamba.git netapi: add ConvertStringSidToSid(). Guenther --- diff --git a/source/lib/netapi/netapi.h b/source/lib/netapi/netapi.h index a1041c009d0..2c6b667123f 100644 --- a/source/lib/netapi/netapi.h +++ b/source/lib/netapi/netapi.h @@ -422,6 +422,21 @@ NET_API_STATUS NetApiBufferFree(void *buffer); int ConvertSidToStringSid(const struct domsid *sid, char **sid_string); +/************************************************************//** + * + * ConvertStringSidToSid + * + * @brief Convert a string into a domain sid + * + * @param[in] sid_string A pointer to a sid string. + * @param[in] sid A pointer that holds a pointer to a sid structure. + * Caller needs to free with free(3) + * @return bool + ***************************************************************/ + +int ConvertStringSidToSid(const char *sid_string, + struct domsid **sid); + /************************************************************//** * * NetJoinDomain diff --git a/source/lib/netapi/sid.c b/source/lib/netapi/sid.c index 4db98bf3d25..a9bca2689fb 100644 --- a/source/lib/netapi/sid.c +++ b/source/lib/netapi/sid.c @@ -48,3 +48,29 @@ int ConvertSidToStringSid(const struct domsid *sid, return true; } + +/**************************************************************** +****************************************************************/ + +int ConvertStringSidToSid(const char *sid_string, + struct domsid **sid) +{ + struct dom_sid _sid; + + if (!sid_string || !sid) { + return false; + } + + if (!string_to_sid(&_sid, sid_string)) { + return false; + } + + *sid = (struct domsid *)SMB_MALLOC(sizeof(struct domsid)); + if (!*sid) { + return false; + } + + sid_copy((struct dom_sid*)*sid, &_sid); + + return true; +}