1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-25 17:57:42 +03:00

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>
This commit is contained in:
Joseph Sutton 2022-11-07 14:28:21 +13:00 committed by Andrew Bartlett
parent 8ef6e7dba7
commit 53d72c87e6

View File

@ -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.
*/