From 5d9069242d3022eaead5de3fcdfab4a2a97c5327 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 4 Mar 2016 15:03:08 +0100 Subject: [PATCH] winbind: Add idmap_backend_unixids_to_sids This is the plural version of idmap_backends_unixid_to_sid that expects all ids to come from the same idmap domain. The singular version walks the domain list itself, this one expects the domain name to be passed to it. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/winbindd/idmap.c | 31 +++++++++++++++++++++++++++++++ source3/winbindd/idmap_proto.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/source3/winbindd/idmap.c b/source3/winbindd/idmap.c index 7b4ed4f05d1..0ff35caacf7 100644 --- a/source3/winbindd/idmap.c +++ b/source3/winbindd/idmap.c @@ -25,6 +25,7 @@ #include "winbindd.h" #include "idmap.h" #include "lib/util_sid_passdb.h" +#include "libcli/security/dom_sid.h" #include "passdb.h" #undef DBGC_CLASS @@ -587,6 +588,36 @@ NTSTATUS idmap_allocate_gid(struct unixid *id) return idmap_allocate_unixid(id); } +NTSTATUS idmap_backend_unixids_to_sids(struct id_map **maps, + const char *domain_name) +{ + struct idmap_domain *dom = NULL; + NTSTATUS status; + bool ok; + + ok = idmap_init(); + if (!ok) { + return NT_STATUS_NONE_MAPPED; + } + + if (strequal(domain_name, get_global_sam_name())) { + dom = passdb_idmap_domain; + } + if (dom == NULL) { + dom = idmap_find_domain(domain_name); + } + if (dom == NULL) { + return NT_STATUS_NONE_MAPPED; + } + + status = dom->methods->unixids_to_sids(dom, maps); + + DBG_DEBUG("unixid_to_sids for domain %s returned %s\n", + domain_name, nt_errstr(status)); + + return status; +} + NTSTATUS idmap_backends_unixid_to_sid(struct id_map *id) { struct idmap_domain *dom; diff --git a/source3/winbindd/idmap_proto.h b/source3/winbindd/idmap_proto.h index 0e124cd8755..78a5c41c8a7 100644 --- a/source3/winbindd/idmap_proto.h +++ b/source3/winbindd/idmap_proto.h @@ -35,6 +35,8 @@ void idmap_close(void); NTSTATUS idmap_allocate_uid(struct unixid *id); NTSTATUS idmap_allocate_gid(struct unixid *id); NTSTATUS idmap_backends_unixid_to_sid(struct id_map *id); +NTSTATUS idmap_backend_unixids_to_sids(struct id_map **maps, + const char *domain_name); /* The following definitions come from winbindd/idmap_nss.c */ -- 2.47.3