summaryrefslogtreecommitdiffstats
path: root/src/providers/ldap/ldap_init.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-05-21 17:18:03 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-06-07 00:14:12 +0200
commitdcb44c39dda9699cdd6488fd116a51ced0687de3 (patch)
tree71b463b2c64a5de1f7c0983d74700b264892bb96 /src/providers/ldap/ldap_init.c
parent7119f0c483049a8850d3075c0b1062f35200a538 (diff)
downloadsssd-dcb44c39dda9699cdd6488fd116a51ced0687de3.tar.gz
sssd-dcb44c39dda9699cdd6488fd116a51ced0687de3.tar.xz
sssd-dcb44c39dda9699cdd6488fd116a51ced0687de3.zip
LDAP: sdap_id_ctx might contain several connections
With some LDAP server implementations, one server might provide different "views" of the identites on different ports. One example is the Active Directory Global catalog. The provider would contact different view depending on which operation it is performing and against which SSSD domain. At the same time, these views run on the same server, which means the same server options, enumeration, cleanup or Kerberos service should be used. So instead of using several different failover ports or several instances of sdap_id_ctx, this patch introduces a new "struct sdap_id_conn_ctx" that contains the connection cache to the particular view and an instance of "struct sdap_options" that contains the URI. No functional changes are present in this patch, currently all providers use a single connection. Multiple connections will be used later in the upcoming patches.
Diffstat (limited to 'src/providers/ldap/ldap_init.c')
-rw-r--r--src/providers/ldap/ldap_init.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/providers/ldap/ldap_init.c b/src/providers/ldap/ldap_init.c
index f70c8f1b0..56339961d 100644
--- a/src/providers/ldap/ldap_init.c
+++ b/src/providers/ldap/ldap_init.c
@@ -87,11 +87,13 @@ int sssm_ldap_id_init(struct be_ctx *bectx,
struct bet_ops **ops,
void **pvt_data)
{
- struct sdap_id_ctx *ctx;
+ struct sdap_id_ctx *ctx = NULL;
const char *urls;
const char *backup_urls;
const char *dns_service_name;
const char *sasl_mech;
+ struct sdap_service *sdap_service;
+ struct sdap_options *opts;
int ret;
/* If we're already set up, just return that */
@@ -103,37 +105,40 @@ int sssm_ldap_id_init(struct be_ctx *bectx,
return EOK;
}
- ctx = talloc_zero(bectx, struct sdap_id_ctx);
- if (!ctx) return ENOMEM;
-
- ctx->be = bectx;
-
- ret = ldap_get_options(ctx, bectx->cdb,
- bectx->conf_path, &ctx->opts);
+ ret = ldap_get_options(bectx, bectx->cdb,
+ bectx->conf_path, &opts);
if (ret != EOK) {
goto done;
}
- dns_service_name = dp_opt_get_string(ctx->opts->basic,
+ dns_service_name = dp_opt_get_string(opts->basic,
SDAP_DNS_SERVICE_NAME);
- DEBUG(7, ("Service name for discovery set to %s\n", dns_service_name));
+ DEBUG(SSSDBG_CONF_SETTINGS,
+ ("Service name for discovery set to %s\n", dns_service_name));
- urls = dp_opt_get_string(ctx->opts->basic, SDAP_URI);
- backup_urls = dp_opt_get_string(ctx->opts->basic, SDAP_BACKUP_URI);
+ urls = dp_opt_get_string(opts->basic, SDAP_URI);
+ backup_urls = dp_opt_get_string(opts->basic, SDAP_BACKUP_URI);
- ret = sdap_service_init(ctx, ctx->be, "LDAP",
+ ret = sdap_service_init(bectx, bectx, "LDAP",
dns_service_name, urls, backup_urls,
- &ctx->service);
+ &sdap_service);
if (ret != EOK) {
- DEBUG(1, ("Failed to initialize failover service!\n"));
+ DEBUG(SSSDBG_OP_FAILURE, ("Failed to initialize failover service!\n"));
goto done;
}
+ ctx = sdap_id_ctx_new(bectx, bectx, sdap_service);
+ if (!ctx) {
+ ret = ENOMEM;
+ goto done;
+ }
+ ctx->opts = talloc_steal(ctx, opts);
+
sasl_mech = dp_opt_get_string(ctx->opts->basic, SDAP_SASL_MECH);
if (sasl_mech && strcasecmp(sasl_mech, "GSSAPI") == 0) {
if (dp_opt_get_bool(ctx->opts->basic, SDAP_KRB5_KINIT)) {
ret = sdap_gssapi_init(ctx, ctx->opts->basic,
- ctx->be, ctx->service,
+ ctx->be, ctx->conn->service,
&ctx->krb5_service);
if (ret != EOK) {
DEBUG(1, ("sdap_gssapi_init failed [%d][%s].\n",
@@ -150,11 +155,6 @@ int sssm_ldap_id_init(struct be_ctx *bectx,
goto done;
}
- ret = sdap_id_conn_cache_create(ctx, ctx, &ctx->conn_cache);
- if (ret != EOK) {
- goto done;
- }
-
/* Set up the ID mapping object */
ret = sdap_idmap_init(ctx, ctx, &ctx->opts->idmap_ctx);
if (ret != EOK) goto done;
@@ -185,6 +185,7 @@ int sssm_ldap_id_init(struct be_ctx *bectx,
done:
if (ret != EOK) {
+ talloc_free(opts);
talloc_free(ctx);
}
return ret;
@@ -208,7 +209,7 @@ int sssm_ldap_auth_init(struct be_ctx *bectx,
ctx->be = bectx;
ctx->opts = id_ctx->opts;
- ctx->service = id_ctx->service;
+ ctx->service = id_ctx->conn->service;
ctx->chpass_service = NULL;
*ops = &sdap_auth_ops;