summaryrefslogtreecommitdiff
path: root/source3/winbindd/idmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/winbindd/idmap.c')
-rw-r--r--source3/winbindd/idmap.c65
1 files changed, 18 insertions, 47 deletions
diff --git a/source3/winbindd/idmap.c b/source3/winbindd/idmap.c
index 2eb655f780..d5eeac659c 100644
--- a/source3/winbindd/idmap.c
+++ b/source3/winbindd/idmap.c
@@ -24,7 +24,7 @@
#include "includes.h"
#include "winbindd.h"
#include "idmap.h"
-#include "passdb/machine_sid.h"
+#include "lib/util_sid_passdb.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_IDMAP
@@ -129,7 +129,7 @@ NTSTATUS smb_register_idmap(int version, const char *name,
for (entry = backends; entry != NULL; entry = entry->next) {
if (strequal(entry->name, name)) {
- DEBUG(0,("Idmap module %s already registered!\n",
+ DEBUG(5,("Idmap module %s already registered!\n",
name));
return NT_STATUS_OBJECT_NAME_COLLISION;
}
@@ -325,7 +325,7 @@ static struct idmap_domain *idmap_init_default_domain(TALLOC_CTX *mem_ctx)
* No config, passdb has its own configuration.
*/
-static struct idmap_domain *idmap_init_passdb_domain(TALLOC_CTX *mem_ctx)
+static struct idmap_domain *idmap_passdb_domain(TALLOC_CTX *mem_ctx)
{
idmap_init();
@@ -367,7 +367,7 @@ static struct idmap_domain *idmap_init_passdb_domain(TALLOC_CTX *mem_ctx)
* add_trusted_domain.
*/
-struct idmap_domain *idmap_find_domain(const char *domname)
+static struct idmap_domain *idmap_find_domain(const char *domname)
{
struct idmap_domain *result;
int i;
@@ -401,7 +401,7 @@ struct idmap_domain *idmap_find_domain(const char *domname)
/*
* talloc context for all idmap domains
*/
- idmap_domains = TALLOC_ARRAY(NULL, struct idmap_domain *, 1);
+ idmap_domains = talloc_array(NULL, struct idmap_domain *, 1);
}
if (idmap_domains == NULL) {
@@ -422,6 +422,18 @@ struct idmap_domain *idmap_find_domain(const char *domname)
return result;
}
+struct idmap_domain *idmap_find_domain_with_sid(const char *domname,
+ const struct dom_sid *sid)
+{
+ idmap_init();
+
+ if (sid_check_is_for_passdb(sid)) {
+ return idmap_passdb_domain(NULL);
+ }
+
+ return idmap_find_domain(domname);
+}
+
void idmap_close(void)
{
TALLOC_FREE(default_idmap_domain);
@@ -483,7 +495,7 @@ NTSTATUS idmap_backends_unixid_to_sid(const char *domname, struct id_map *id)
* Always give passdb a chance first
*/
- dom = idmap_init_passdb_domain(NULL);
+ dom = idmap_passdb_domain(NULL);
if ((dom != NULL)
&& NT_STATUS_IS_OK(dom->methods->unixids_to_sids(dom, maps))
&& id->status == ID_MAPPED) {
@@ -497,44 +509,3 @@ NTSTATUS idmap_backends_unixid_to_sid(const char *domname, struct id_map *id)
return dom->methods->unixids_to_sids(dom, maps);
}
-
-NTSTATUS idmap_backends_sid_to_unixid(const char *domain, struct id_map *id)
-{
- struct idmap_domain *dom;
- struct id_map *maps[2];
-
- DEBUG(10, ("idmap_backends_sid_to_unixid: domain = '%s', sid = [%s]\n",
- domain?domain:"NULL", sid_string_dbg(id->sid)));
-
- maps[0] = id;
- maps[1] = NULL;
-
- if (sid_check_is_in_builtin(id->sid)
- || (sid_check_is_in_our_domain(id->sid)))
- {
- NTSTATUS status;
-
- DEBUG(10, ("asking passdb...\n"));
-
- dom = idmap_init_passdb_domain(NULL);
- if (dom == NULL) {
- return NT_STATUS_NONE_MAPPED;
- }
- status = dom->methods->sids_to_unixids(dom, maps);
-
- if (NT_STATUS_IS_OK(status) && id->status == ID_MAPPED) {
- return status;
- }
-
- DEBUG(10, ("passdb could not map.\n"));
-
- return NT_STATUS_NONE_MAPPED;
- }
-
- dom = idmap_find_domain(domain);
- if (dom == NULL) {
- return NT_STATUS_NONE_MAPPED;
- }
-
- return dom->methods->sids_to_unixids(dom, maps);
-}