From: Stefan Metzmacher Date: Thu, 11 May 2017 15:05:02 +0000 (+0200) Subject: s4:auth: add authenticate_ldap_simple_bind_send/recv X-Git-Tag: ldb-1.1.31~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e165ca85ae8049a7fb9a5535c168d1b9cb5ec26;p=thirdparty%2Fsamba.git s4:auth: add authenticate_ldap_simple_bind_send/recv TODO: we need to make the backend async. Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett --- diff --git a/source4/auth/auth.h b/source4/auth/auth.h index c12e233219f..2dc0d8c7997 100644 --- a/source4/auth/auth.h +++ b/source4/auth/auth.h @@ -160,6 +160,18 @@ NTSTATUS auth_check_password(struct auth4_context *auth_ctx, NTSTATUS auth4_init(void); NTSTATUS auth_register(TALLOC_CTX *mem_ctx, const struct auth_operations *ops); NTSTATUS server_service_auth_init(TALLOC_CTX *ctx); +struct tevent_req *authenticate_ldap_simple_bind_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct imessaging_context *msg, + struct loadparm_context *lp_ctx, + struct tsocket_address *remote_address, + struct tsocket_address *local_address, + bool using_tls, + const char *dn, + const char *password); +NTSTATUS authenticate_ldap_simple_bind_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + struct auth_session_info **session_info); NTSTATUS authenticate_ldap_simple_bind(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct imessaging_context *msg, diff --git a/source4/auth/ntlm/auth_simple.c b/source4/auth/ntlm/auth_simple.c index cd96113ca03..142bd401c9f 100644 --- a/source4/auth/ntlm/auth_simple.c +++ b/source4/auth/ntlm/auth_simple.c @@ -22,9 +22,49 @@ */ #include "includes.h" +#include +#include "lib/util/tevent_ntstatus.h" #include "auth/auth.h" #include "dsdb/samdb/samdb.h" +struct authenticate_ldap_simple_bind_state { + struct auth_session_info *session_info; +}; + +_PUBLIC_ struct tevent_req *authenticate_ldap_simple_bind_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct imessaging_context *msg, + struct loadparm_context *lp_ctx, + struct tsocket_address *remote_address, + struct tsocket_address *local_address, + bool using_tls, + const char *dn, + const char *password) +{ + struct tevent_req *req = NULL; + struct authenticate_ldap_simple_bind_state *state = NULL; + NTSTATUS status; + + req = tevent_req_create(mem_ctx, &state, + struct authenticate_ldap_simple_bind_state); + if (req == NULL) { + return NULL; + } + + status = authenticate_ldap_simple_bind(state, ev, msg, lp_ctx, + remote_address, + local_address, + using_tls, + dn, password, + &state->session_info); + if (tevent_req_nterror(req, status)) { + return tevent_req_post(req, ev); + } + + tevent_req_done(req); + return tevent_req_post(req, ev); +} + _PUBLIC_ NTSTATUS authenticate_ldap_simple_bind(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct imessaging_context *msg, @@ -154,3 +194,23 @@ _PUBLIC_ NTSTATUS authenticate_ldap_simple_bind(TALLOC_CTX *mem_ctx, return nt_status; } +_PUBLIC_ NTSTATUS authenticate_ldap_simple_bind_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + struct auth_session_info **session_info) +{ + struct authenticate_ldap_simple_bind_state *state = + tevent_req_data(req, + struct authenticate_ldap_simple_bind_state); + NTSTATUS status; + + *session_info = NULL; + + if (tevent_req_is_nterror(req, &status)) { + tevent_req_received(req); + return status; + } + + *session_info = talloc_move(mem_ctx, &state->session_info); + tevent_req_received(req); + return NT_STATUS_OK; +}