winbind: Add idmap_backend_unixids_to_sids
authorVolker Lendecke <vl@samba.org>
Fri, 4 Mar 2016 14:03:08 +0000 (15:03 +0100)
committerVolker Lendecke <vl@samba.org>
Wed, 30 Mar 2016 12:27:23 +0000 (14:27 +0200)
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 <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/winbindd/idmap.c
source3/winbindd/idmap_proto.h

index 7b4ed4f05d12789fc79f6709faec60f903221771..0ff35caacf745ccea2263136b0e465a012b3218e 100644 (file)
@@ -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;
index 0e124cd8755d717de60f7c356ac4e2407658cb80..78a5c41c8a74a5fa367d65e48994426b04ef0d75 100644 (file)
@@ -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  */