From c7c35108105eea60e3cf81f2d53d241889349c91 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Aug 2008 15:15:05 +0200 Subject: netapi: add ConvertStringSidToSid(). Guenther (This used to be commit 36f1e45e4ec295115f1ba39ec7ad3690a96dac3e) --- source3/lib/netapi/netapi.h | 15 +++++++++++++++ source3/lib/netapi/sid.c | 26 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h index a1041c009d..2c6b667123 100644 --- a/source3/lib/netapi/netapi.h +++ b/source3/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/source3/lib/netapi/sid.c b/source3/lib/netapi/sid.c index 4db98bf3d2..a9bca2689f 100644 --- a/source3/lib/netapi/sid.c +++ b/source3/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; +} -- cgit