summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorJoseph Sutton <josephsutton@catalyst.net.nz>2022-11-07 14:28:21 +1300
committerAndrew Bartlett <abartlet@samba.org>2023-02-08 00:03:39 +0000
commit53d72c87e6362e24eb922a5a9040e5d631c7fce4 (patch)
treea01f33dbe23f9e5f3ff890315261634cb6400c27 /source4/dsdb
parent8ef6e7dba7f243310db3d9769f3fb4a3ad4d6daa (diff)
downloadsamba-53d72c87e6362e24eb922a5a9040e5d631c7fce4.tar.gz
s4-dsdb: Add samdb_result_dom_sid_attrs()
This function is modelled on samdb_result_dom_sid(). It allocates, rather than a dom_sid, an auth_SidAttr object, which we can pass to other functions accepting an auth_SidAttr. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/common/util.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index 0167267d370..2cde400daa6 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -49,6 +49,7 @@
#include "lib/util/sys_rw_data.h"
#include "libcli/util/ntstatus.h"
#include "lib/util/smb_strtox.h"
+#include "auth/auth.h"
#undef strncasecmp
#undef strcasecmp
@@ -365,6 +366,40 @@ struct dom_sid *samdb_result_dom_sid(TALLOC_CTX *mem_ctx, const struct ldb_messa
return sid;
}
+
+/**
+ * Makes an auth_SidAttr structure from a objectSid in a result set and a
+ * supplied attribute value.
+ *
+ * @param [in] mem_ctx Talloc memory context on which to allocate the auth_SidAttr.
+ * @param [in] msg The message from which to take the objectSid.
+ * @param [in] attr The attribute name, usually "objectSid".
+ * @param [in] attrs SE_GROUP_* flags to go with the SID.
+ * @returns A pointer to the auth_SidAttr structure, or NULL on failure.
+ */
+struct auth_SidAttr *samdb_result_dom_sid_attrs(TALLOC_CTX *mem_ctx, const struct ldb_message *msg,
+ const char *attr, uint32_t attrs)
+{
+ ssize_t ret;
+ const struct ldb_val *v;
+ struct auth_SidAttr *sid;
+ v = ldb_msg_find_ldb_val(msg, attr);
+ if (v == NULL) {
+ return NULL;
+ }
+ sid = talloc(mem_ctx, struct auth_SidAttr);
+ if (sid == NULL) {
+ return NULL;
+ }
+ ret = sid_parse(v->data, v->length, &sid->sid);
+ if (ret == -1) {
+ talloc_free(sid);
+ return NULL;
+ }
+ sid->attrs = attrs;
+ return sid;
+}
+
/*
pull a guid structure from a objectGUID in a result set.
*/