/** Parse a bind response from a server * * @param[in] el the event occurred in. * @param[in] fd the event occurred on. * @param[in] flags from kevent. * @param[in] uctx bind_ctx containing credentials, and connection config/handle. */ static void _ldap_bind_io_read(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx) { fr_ldap_bind_ctx_t *bind_ctx = talloc_get_type_abort(uctx, fr_ldap_bind_ctx_t); fr_ldap_connection_t *c = bind_ctx->c; fr_ldap_rcode_t status; struct timeval tv = { 0, 0 }; /* We're I/O driven, if there's no data someone lied to us */ status = fr_ldap_result(NULL, NULL, c, bind_ctx->msgid, LDAP_MSG_ALL, bind_ctx->bind_dn, &tv); talloc_free(bind_ctx); /* Also removes fd events */ switch (status) { case LDAP_PROC_SUCCESS: DEBUG("Bind successful"); fr_ldap_state_next(c); /* onto the next operation */ break; case LDAP_PROC_NOT_PERMITTED: PERROR("Bind as \"%s\" to \"%s\" not permitted", *bind_ctx->bind_dn ? bind_ctx->bind_dn : "(anonymous)", c->config->server); fr_ldap_state_error(c); /* Restart the connection state machine */ break; default: PERROR("Bind as \"%s\" to \"%s\" failed", *bind_ctx->bind_dn ? bind_ctx->bind_dn : "(anonymous)", c->config->server); fr_ldap_state_error(c); /* Restart the connection state machine */ break; } }
/** Signal that there's been an error on the connection * */ void fr_ldap_state_error(fr_ldap_connection_t *c) { STATE_TRANSITION(FR_LDAP_STATE_ERROR); fr_ldap_state_next(c); }