Lines Matching refs:state

71     struct sdap_connect_state *state;
75 req = tevent_req_create(memctx, &state, struct sdap_connect_state);
84 state->reply = talloc(state, struct sdap_msg);
85 if (!state->reply) {
90 state->ev = ev;
91 state->opts = opts;
92 state->use_start_tls = use_start_tls;
94 state->uri = talloc_asprintf(state, "%s", uri);
95 if (!state->uri) {
100 state->sh = sdap_handle_create(state);
101 if (!state->sh) {
106 state->sh->page_size = dp_opt_get_int(state->opts->basic,
109 timeout = dp_opt_get_int(state->opts->basic, SDAP_NETWORK_TIMEOUT);
111 subreq = sss_ldap_init_send(state, ev, state->uri, sockaddr,
133 struct sdap_connect_state *state = tevent_req_data(req,
152 ret = sss_ldap_init_recv(subreq, &state->sh->ldap, &sd);
162 ret = setup_ldap_connection_callbacks(state->sh, state->ev);
174 ret = sdap_call_conn_cb(state->uri, sd, state->sh);
183 lret = ldap_set_option(state->sh->ldap, LDAP_OPT_PROTOCOL_VERSION, &ver);
191 ret = ldap_set_option(state->sh->ldap, LDAP_OPT_RESTART, LDAP_OPT_ON);
197 tv.tv_sec = dp_opt_get_int(state->opts->basic, SDAP_NETWORK_TIMEOUT);
199 lret = ldap_set_option(state->sh->ldap, LDAP_OPT_NETWORK_TIMEOUT, &tv);
202 dp_opt_get_int(state->opts->basic, SDAP_NETWORK_TIMEOUT));
207 tv.tv_sec = dp_opt_get_int(state->opts->basic, SDAP_OPT_TIMEOUT);
209 lret = ldap_set_option(state->sh->ldap, LDAP_OPT_TIMEOUT, &tv);
212 dp_opt_get_int(state->opts->basic, SDAP_OPT_TIMEOUT));
217 ldap_referrals = dp_opt_get_bool(state->opts->basic, SDAP_REFERRALS);
218 lret = ldap_set_option(state->sh->ldap, LDAP_OPT_REFERRALS,
227 rebind_proc_params = talloc_zero(state->sh,
235 rebind_proc_params->opts = state->opts;
236 rebind_proc_params->sh = state->sh;
237 rebind_proc_params->use_start_tls = state->use_start_tls;
239 lret = ldap_set_rebind_proc(state->sh->ldap, sdap_rebind_proc,
248 ldap_deref = dp_opt_get_string(state->opts->basic, SDAP_DEREF);
256 lret = ldap_set_option(state->sh->ldap, LDAP_OPT_DEREF, &ldap_deref_val);
266 sasl_nocanon = !dp_opt_get_bool(state->opts->basic, SDAP_SASL_CANONICALIZE);
267 lret = ldap_set_option(state->sh->ldap, LDAP_OPT_X_SASL_NOCANON,
281 sasl_mech = dp_opt_get_string(state->opts->basic, SDAP_SASL_MECH);
283 sasl_minssf = dp_opt_get_int(state->opts->basic, SDAP_SASL_MINSSF);
286 lret = ldap_set_option(state->sh->ldap, LDAP_OPT_X_SASL_SSF_MIN,
298 if (!state->use_start_tls) {
305 lret = ldap_start_tls(state->sh->ldap, NULL, NULL, &msgid);
307 optret = sss_ldap_get_diagnostic_msg(state, state->sh->ldap,
324 ret = sdap_set_connected(state->sh, state->ev);
327 ret = sdap_op_add(state, state->ev, state->sh, msgid,
329 dp_opt_get_int(state->opts->basic, SDAP_OPT_TIMEOUT),
330 &state->op);
356 struct sdap_connect_state *state = tevent_req_data(req,
368 state->reply = talloc_steal(state, reply);
370 ret = ldap_parse_result(state->sh->ldap, state->reply->msg,
371 &state->result, NULL, &errmsg, NULL, NULL, 0);
374 "ldap_parse_result failed (%d)\n", state->op->msgid);
380 sss_ldap_err2string(state->result), state->result, errmsg);
383 if (ldap_tls_inplace(state->sh->ldap)) {
390 ret = ldap_install_tls(state->sh->ldap);
393 optret = sss_ldap_get_diagnostic_msg(state, state->sh->ldap,
408 state->result = ret;
420 struct sdap_connect_state *state = tevent_req_data(req,
425 *sh = talloc_steal(memctx, state->sh);
458 struct sdap_connect_host_state *state = NULL;
463 req = tevent_req_create(mem_ctx, &state,
470 state->ev = ev;
471 state->opts = opts;
472 state->port = port;
473 state->use_start_tls = use_start_tls;
475 state->protocol = talloc_strdup(state, protocol);
476 if (state->protocol == NULL) {
481 state->host = talloc_strdup(state, host);
482 if (state->host == NULL) {
487 state->uri = talloc_asprintf(state, "%s://%s:%d", protocol, host, port);
488 if (state->uri == NULL) {
495 subreq = resolv_gethostbyname_send(state, state->ev, resolv_ctx,
520 struct sdap_connect_host_state *state = NULL;
527 state = tevent_req_data(req, struct sdap_connect_host_state);
529 ret = resolv_gethostbyname_recv(subreq, state, &status, NULL, &hostent);
533 state->host, resolv_strerror(status));
537 sockaddr = resolv_get_sockaddr_address(state, hostent, state->port);
544 DEBUG(SSSDBG_TRACE_FUNC, "Connecting to %s\n", state->uri);
546 subreq = sdap_connect_send(state, state->ev, state->opts,
547 state->uri, sockaddr, state->use_start_tls);
569 struct sdap_connect_host_state *state = NULL;
574 state = tevent_req_data(req, struct sdap_connect_host_state);
576 ret = sdap_connect_recv(subreq, state, &state->sh);
583 if (!state->use_start_tls) {
585 ret = sdap_set_connected(state->sh, state->ev);
592 DEBUG(SSSDBG_TRACE_FUNC, "Successful connection to %s\n", state->uri);
607 struct sdap_connect_host_state *state = NULL;
608 state = tevent_req_data(req, struct sdap_connect_host_state);
612 *_sh = talloc_steal(mem_ctx, state->sh);
644 struct simple_bind_state *state;
651 req = tevent_req_create(memctx, &state, struct simple_bind_state);
654 state->reply = talloc(state, struct sdap_msg);
655 if (!state->reply) {
660 state->ev = ev;
661 state->sh = sh;
662 state->user_dn = user_dn;
663 state->pw = pw;
675 "Executing simple bind as: %s\n", state->user_dn);
677 ret = ldap_sasl_bind(state->sh->ldap, state->user_dn, LDAP_SASL_SIMPLE,
681 ret = ldap_get_option(state->sh->ldap,
701 ret = sdap_op_add(state, ev, sh, msgid,
702 simple_bind_done, req, timeout, &state->op);
725 struct simple_bind_state *state = tevent_req_data(req,
743 state->reply = talloc_steal(state, reply);
745 lret = ldap_parse_result(state->sh->ldap, state->reply->msg,
750 "ldap_parse_result failed (%d)\n", state->op->msgid);
769 state->ppolicy = NULL;
777 lret = ldap_parse_passwordpolicy_control(state->sh->ldap,
792 if (!state->ppolicy)
793 state->ppolicy = talloc_zero(state,
795 if (state->ppolicy == NULL) {
799 state->ppolicy->grace = pp_grace;
800 state->ppolicy->expire = pp_expire;
836 if (!state->ppolicy) {
837 state->ppolicy = talloc(state, struct sdap_ppolicy_data);
840 if (state->ppolicy == NULL) {
852 state->ppolicy->expire = strtouint32(nval, NULL, 10);
865 state->ppolicy->expire);
893 struct simple_bind_state *state = tevent_req_data(req,
897 *ppolicy = talloc_steal(memctx, state->ppolicy);
927 struct sasl_bind_state *state;
932 req = tevent_req_create(memctx, &state, struct sasl_bind_state);
935 state->ev = ev;
936 state->sh = sh;
937 state->sasl_mech = sasl_mech;
938 state->sasl_user = sasl_user;
939 state->sasl_cred = sasl_cred;
947 if (state->sh == NULL || state->sh->ldap == NULL) {
954 ret = ldap_sasl_interactive_bind_s(state->sh->ldap, NULL,
957 (*sdap_sasl_interact), state);
963 optret = sss_ldap_get_diagnostic_msg(state, state->sh->ldap,
980 * set the state but will not complain if no callback has been set.
983 * state value set previously by tevent_req_done() */
1001 struct sasl_bind_state *state = talloc_get_type(defaults,
1021 if (state->sasl_user) {
1022 in->result = state->sasl_user;
1087 struct sdap_kinit_state *state;
1099 req = tevent_req_create(memctx, &state, struct sdap_kinit_state);
1102 state->keytab = keytab;
1103 state->principal = principal;
1104 state->realm = realm;
1105 state->ev = ev;
1106 state->be = be;
1107 state->timeout = timeout;
1108 state->lifetime = lifetime;
1109 state->krb_service_name = krb_service_name;
1135 struct sdap_kinit_state *state = tevent_req_data(req,
1139 "Resolving next KDC for service %s\n", state->krb_service_name);
1141 next_req = be_resolve_server_send(state, state->ev,
1142 state->be,
1143 state->krb_service_name,
1144 state->kdc_srv == NULL ? true : false);
1158 struct sdap_kinit_state *state = tevent_req_data(req,
1163 ret = be_resolve_server_recv(subreq, state, &state->kdc_srv);
1174 tgtreq = sdap_get_tgt_send(state, state->ev, state->realm,
1175 state->principal, state->keytab,
1176 state->lifetime, state->timeout);
1188 struct sdap_kinit_state *state = tevent_req_data(req,
1198 ret = sdap_get_tgt_recv(subreq, state, &result,
1206 be_fo_set_port_status(state->be, state->krb_service_name,
1207 state->kdc_srv, PORT_NOT_WORKING);
1230 state->expire_time = expire_time;
1235 be_fo_set_port_status(state->be, state->krb_service_name,
1236 state->kdc_srv, PORT_NOT_WORKING);
1254 struct sdap_kinit_state *state = tevent_req_data(req,
1270 *expire_time = state->expire_time;
1295 struct sdap_auth_state *state;
1297 req = tevent_req_create(memctx, &state, struct sdap_auth_state);
1301 state->is_sasl = true;
1302 subreq = sasl_bind_send(state, ev, sh, sasl_mech, sasl_user, NULL);
1327 state->is_sasl = false;
1328 subreq = simple_bind_send(state, ev, sh, simple_bind_timeout, user_dn, &pw);
1363 struct sdap_auth_state *state = tevent_req_data(req,
1367 if (state->is_sasl) {
1369 state->ppolicy = NULL;
1371 ret = simple_bind_recv(subreq, state, &state->ppolicy);
1385 struct sdap_auth_state *state = tevent_req_data(req,
1389 *ppolicy = talloc_steal(memctx, state->ppolicy);
1424 static errno_t sdap_cli_use_rootdse(struct sdap_cli_connect_state *state);
1473 struct sdap_cli_connect_state *state;
1477 req = tevent_req_create(memctx, &state, struct sdap_cli_connect_state);
1480 state->ev = ev;
1481 state->opts = opts;
1482 state->service = service;
1483 state->be = be;
1484 state->srv = NULL;
1485 state->srv_opts = NULL;
1486 state->use_rootdse = !skip_rootdse;
1487 state->force_tls = force_tls;
1488 state->do_auth = !skip_auth;
1500 struct sdap_cli_connect_state *state = tevent_req_data(req,
1505 talloc_zfree(state->sh);
1509 subreq = be_resolve_server_send(state, state->ev,
1510 state->be, state->service->name,
1511 state->srv == NULL ? true : false);
1524 struct sdap_cli_connect_state *state = tevent_req_data(req,
1528 ret = be_resolve_server_recv(subreq, state, &state->srv);
1531 state->srv = NULL;
1538 ret = decide_tls_usage(state->force_tls, state->opts->basic,
1539 state->service->uri, &state->use_tls);
1546 subreq = sdap_connect_send(state, state->ev, state->opts,
1547 state->service->uri,
1548 state->service->sockaddr,
1549 state->use_tls);
1561 struct sdap_cli_connect_state *state = tevent_req_data(req,
1566 talloc_zfree(state->sh);
1567 ret = sdap_connect_recv(subreq, state, &state->sh);
1571 be_fo_set_port_status(state->be, state->service->name,
1572 state->srv, PORT_NOT_WORKING);
1580 if (state->use_rootdse) {
1586 sasl_mech = dp_opt_get_string(state->opts->basic, SDAP_SASL_MECH);
1588 if (state->do_auth && sasl_mech && state->use_rootdse) {
1590 if (!sdap_is_sasl_mech_supported(state->sh, sasl_mech)) {
1596 if (state->do_auth && sasl_mech && (strcasecmp(sasl_mech, "GSSAPI") == 0)) {
1597 if (dp_opt_get_bool(state->opts->basic, SDAP_KRB5_KINIT)) {
1608 struct sdap_cli_connect_state *state = tevent_req_data(req,
1613 subreq = sdap_get_rootdse_send(state, state->ev, state->opts, state->sh);
1620 if (!state->sh->connected) {
1625 ret = sdap_set_connected(state->sh, state->ev);
1636 struct sdap_cli_connect_state *state = tevent_req_data(req,
1641 ret = sdap_get_rootdse_recv(subreq, state, &state->rootdse);
1645 be_fo_set_port_status(state->be, state->service->name,
1646 state->srv, PORT_NOT_WORKING);
1660 state->rootdse = NULL;
1664 ret = sdap_cli_use_rootdse(state);
1671 sasl_mech = dp_opt_get_string(state->opts->basic, SDAP_SASL_MECH);
1673 if (state->do_auth && sasl_mech && state->rootdse) {
1675 if (!sdap_is_sasl_mech_supported(state->sh, sasl_mech)) {
1681 if (state->do_auth && sasl_mech && (strcasecmp(sasl_mech, "GSSAPI") == 0)) {
1682 if (dp_opt_get_bool(state->opts->basic, SDAP_KRB5_KINIT)) {
1691 static errno_t sdap_cli_use_rootdse(struct sdap_cli_connect_state *state)
1695 if (state->rootdse) {
1697 ret = sdap_set_rootdse_supported_lists(state->rootdse, state->sh);
1704 ret = sdap_set_config_options_with_rootdse(state->rootdse, state->opts,
1705 state->opts->sdom);
1714 ret = sdap_get_server_opts_from_rootdse(state,
1715 state->service->uri,
1716 state->rootdse,
1717 state->opts, &state->srv_opts);
1729 struct sdap_cli_connect_state *state = tevent_req_data(req,
1733 subreq = sdap_kinit_send(state, state->ev,
1734 state->be,
1735 state->sh,
1736 state->service->kinit_service_name,
1737 dp_opt_get_int(state->opts->basic,
1739 dp_opt_get_string(state->opts->basic,
1741 dp_opt_get_string(state->opts->basic,
1743 sdap_gssapi_realm(state->opts->basic),
1744 dp_opt_get_bool(state->opts->basic,
1746 dp_opt_get_int(state->opts->basic,
1759 struct sdap_cli_connect_state *state = tevent_req_data(req,
1774 state->sh->expire_time = expire_time;
1781 struct sdap_cli_connect_state *state = tevent_req_data(req,
1786 const char *sasl_mech = dp_opt_get_string(state->opts->basic,
1788 const char *user_dn = dp_opt_get_string(state->opts->basic,
1797 if (state->sh == NULL || !state->sh->connected) {
1814 expire_timeout = dp_opt_get_int(state->opts->basic, SDAP_EXPIRE_TIMEOUT);
1816 if (!state->sh->expire_time
1817 || (state->sh->expire_time > (now + expire_timeout))) {
1818 state->sh->expire_time = now + expire_timeout;
1820 "the connection will expire at %ld\n", state->sh->expire_time);
1823 if (!state->do_auth ||
1831 authtok_type = dp_opt_get_string(state->opts->basic,
1833 authtok = sss_authtok_new(state);
1846 authtok_blob = dp_opt_get_blob(state->opts->basic,
1859 subreq = sdap_auth_send(state, state->ev,
1860 state->sh, sasl_mech,
1861 dp_opt_get_string(state->opts->basic,
1864 dp_opt_get_int(state->opts->basic,
1875 struct sdap_cli_connect_state *state;
1879 state = tevent_req_data(req, struct sdap_cli_connect_state);
1881 ret = decide_tls_usage(state->force_tls, state->opts->basic,
1882 state->service->uri, &state->use_tls);
1887 subreq = sdap_connect_send(state, state->ev, state->opts,
1888 state->service->uri,
1889 state->service->sockaddr,
1890 state->use_tls);
1907 struct sdap_cli_connect_state *state;
1912 state = tevent_req_data(req, struct sdap_cli_connect_state);
1914 talloc_zfree(state->sh);
1916 ret = sdap_connect_recv(subreq, state, &state->sh);
1923 if (!state->use_tls) {
1925 ret = sdap_set_connected(state->sh, state->ev);
1933 if (state->sh == NULL || !state->sh->connected) {
1953 struct sdap_cli_connect_state *state = tevent_req_data(req,
1964 if (state->use_rootdse && !state->rootdse) {
1967 subreq = sdap_get_rootdse_send(state, state->ev,
1968 state->opts, state->sh);
1985 struct sdap_cli_connect_state *state = tevent_req_data(req,
1988 ret = sdap_get_rootdse_recv(subreq, state, &state->rootdse);
1994 be_fo_set_port_status(state->be, state->service->name,
1995 state->srv, PORT_NOT_WORKING);
2009 state->use_rootdse = false;
2010 state->rootdse = NULL;
2016 ret = sdap_cli_use_rootdse(state);
2032 struct sdap_cli_connect_state *state = tevent_req_data(req,
2043 if (state->srv) {
2047 be_fo_set_port_status(state->be, state->service->name,
2048 state->srv, PORT_NOT_WORKING);
2063 } else if (state->srv) {
2066 be_fo_set_port_status(state->be, state->service->name,
2067 state->srv, PORT_WORKING);
2074 *gsh = talloc_steal(memctx, state->sh);
2079 talloc_zfree(state->sh);
2083 *srv_opts = talloc_steal(memctx, state->srv_opts);