Example #1
0
static struct idmap_domain *idmap_init_passdb_domain(TALLOC_CTX *mem_ctx)
{
	idmap_init();

	/*
	 * Always init the default domain, we can't go without one
	 */
	if (default_idmap_domain == NULL) {
		default_idmap_domain = idmap_init_default_domain(NULL);
	}
	if (default_idmap_domain == NULL) {
		return NULL;
	}

	if (passdb_idmap_domain != NULL) {
		return passdb_idmap_domain;
	}

	passdb_idmap_domain = idmap_init_domain(NULL, get_global_sam_name(),
						"passdb", false);
	if (passdb_idmap_domain == NULL) {
		DEBUG(1, ("Could not init passdb idmap domain\n"));
	}

	return passdb_idmap_domain;
}
Example #2
0
static struct idmap_domain *idmap_init_named_domain(TALLOC_CTX *mem_ctx,
						    const char *domname)
{
	struct idmap_domain *result = NULL;
	char *config_option;
	const char *backend;

	idmap_init();

	config_option = talloc_asprintf(talloc_tos(), "idmap config %s",
					domname);
	if (config_option == NULL) {
		DEBUG(0, ("talloc failed\n"));
		goto fail;
	}

	backend = lp_parm_const_string(-1, config_option, "backend", NULL);
	if (backend == NULL) {
		DEBUG(1, ("no backend defined for %s\n", config_option));
		goto fail;
	}

	result = idmap_init_domain(mem_ctx, domname, backend, true);
	if (result == NULL) {
		goto fail;
	}

	TALLOC_FREE(config_option);
	return result;

fail:
	TALLOC_FREE(config_option);
	TALLOC_FREE(result);
	return NULL;
}
static struct idmap_domain *idmap_init_default_domain(TALLOC_CTX *mem_ctx)
{
	struct idmap_domain *result;
	char *modulename;
	char *params;

	DEBUG(10, ("idmap_init_default_domain: calling static_init_idmap\n"));

	static_init_idmap;

	if (!parse_idmap_module(talloc_tos(), lp_idmap_backend(), &modulename,
				&params)) {
		DEBUG(1, ("parse_idmap_module failed\n"));
		return NULL;
	}

	DEBUG(3, ("idmap_init: using '%s' as remote backend\n", modulename));

	result = idmap_init_domain(mem_ctx, "*", modulename, params);
	if (result == NULL) {
		goto fail;
	}

	TALLOC_FREE(modulename);
	TALLOC_FREE(params);
	return result;

fail:
	TALLOC_FREE(modulename);
	TALLOC_FREE(params);
	TALLOC_FREE(result);
	return NULL;
}
static struct idmap_domain *idmap_init_passdb_domain(TALLOC_CTX *mem_ctx)
{
	if (passdb_idmap_domain != NULL) {
		return passdb_idmap_domain;
	}

	passdb_idmap_domain = idmap_init_domain(NULL, get_global_sam_name(),
						"passdb", NULL);
	if (passdb_idmap_domain == NULL) {
		DEBUG(1, ("Could not init passdb idmap domain\n"));
	}

	return passdb_idmap_domain;
}