From 822554137f72a0f28a485ce307e16c4b5fa7200b Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Mon, 11 Apr 2011 21:49:03 +0200 Subject: Initialise srv_opts even if rootDSE is missing --- src/providers/ldap/sdap.c | 78 +++++++++++++++--------------- src/providers/ldap/sdap_async_connection.c | 17 ++++--- 2 files changed, 49 insertions(+), 46 deletions(-) diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c index 95c39a0c9..237a1f230 100644 --- a/src/providers/ldap/sdap.c +++ b/src/providers/ldap/sdap.c @@ -606,46 +606,48 @@ int sdap_get_server_opts_from_rootdse(TALLOC_CTX *memctx, last_usn_name = opts->gen_map[SDAP_AT_LAST_USN].name; entry_usn_name = opts->gen_map[SDAP_AT_ENTRY_USN].name; - if (last_usn_name) { - ret = sysdb_attrs_get_string(rootdse, - last_usn_name, &last_usn_value); - if (ret != EOK) { - switch (ret) { - case ENOENT: - DEBUG(1, ("%s configured but not found in rootdse!\n", - opts->gen_map[SDAP_AT_LAST_USN].opt_name)); - break; - case ERANGE: - DEBUG(1, ("Multiple values of %s found in rootdse!\n", - opts->gen_map[SDAP_AT_LAST_USN].opt_name)); - break; - default: - DEBUG(1, ("Unkown error (%d) checking rootdse!\n", ret)); - } - } else { - if (!entry_usn_name) { - DEBUG(1, ("%s found in rootdse but %s is not set!\n", - last_usn_name, - opts->gen_map[SDAP_AT_ENTRY_USN].opt_name)); + if (rootdse) { + if (last_usn_name) { + ret = sysdb_attrs_get_string(rootdse, + last_usn_name, &last_usn_value); + if (ret != EOK) { + switch (ret) { + case ENOENT: + DEBUG(1, ("%s configured but not found in rootdse!\n", + opts->gen_map[SDAP_AT_LAST_USN].opt_name)); + break; + case ERANGE: + DEBUG(1, ("Multiple values of %s found in rootdse!\n", + opts->gen_map[SDAP_AT_LAST_USN].opt_name)); + break; + default: + DEBUG(1, ("Unkown error (%d) checking rootdse!\n", ret)); + } } else { - so->supports_usn = true; + if (!entry_usn_name) { + DEBUG(1, ("%s found in rootdse but %s is not set!\n", + last_usn_name, + opts->gen_map[SDAP_AT_ENTRY_USN].opt_name)); + } else { + so->supports_usn = true; + } } - } - } else { - /* no usn option configure, let's try to autodetect. */ - for (i = 0; usn_attrs[i].last_name; i++) { - ret = sysdb_attrs_get_string(rootdse, - usn_attrs[i].last_name, - &last_usn_value); - if (ret == EOK) { - /* Fixate discovered configuration */ - opts->gen_map[SDAP_AT_LAST_USN].name = - talloc_strdup(opts->gen_map, usn_attrs[i].last_name); - opts->gen_map[SDAP_AT_ENTRY_USN].name = - talloc_strdup(opts->gen_map, usn_attrs[i].entry_name); - so->supports_usn = true; - last_usn_name = usn_attrs[i].last_name; - break; + } else { + /* no usn option configure, let's try to autodetect. */ + for (i = 0; usn_attrs[i].last_name; i++) { + ret = sysdb_attrs_get_string(rootdse, + usn_attrs[i].last_name, + &last_usn_value); + if (ret == EOK) { + /* Fixate discovered configuration */ + opts->gen_map[SDAP_AT_LAST_USN].name = + talloc_strdup(opts->gen_map, usn_attrs[i].last_name); + opts->gen_map[SDAP_AT_ENTRY_USN].name = + talloc_strdup(opts->gen_map, usn_attrs[i].entry_name); + so->supports_usn = true; + last_usn_name = usn_attrs[i].last_name; + break; + } } } } diff --git a/src/providers/ldap/sdap_async_connection.c b/src/providers/ldap/sdap_async_connection.c index fbbb44479..bae412c7b 100644 --- a/src/providers/ldap/sdap_async_connection.c +++ b/src/providers/ldap/sdap_async_connection.c @@ -1285,14 +1285,15 @@ static void sdap_cli_rootdse_done(struct tevent_req *subreq) return; } - ret = sdap_get_server_opts_from_rootdse(state, - state->service->uri, rootdse, - state->opts, &state->srv_opts); - if (ret) { - DEBUG(1, ("sdap_get_server_opts_from_rootdse failed.\n")); - tevent_req_error(req, ret); - return; - } + } + + ret = sdap_get_server_opts_from_rootdse(state, + state->service->uri, rootdse, + state->opts, &state->srv_opts); + if (ret) { + DEBUG(1, ("sdap_get_server_opts_from_rootdse failed.\n")); + tevent_req_error(req, ret); + return; } sasl_mech = dp_opt_get_string(state->opts->basic, SDAP_SASL_MECH); -- cgit