s4:auth: add authenticate_ldap_simple_bind_send/recv
authorStefan Metzmacher <metze@samba.org>
Thu, 11 May 2017 15:05:02 +0000 (17:05 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 15 Jun 2017 07:13:23 +0000 (09:13 +0200)
TODO: we need to make the backend async.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/auth/auth.h
source4/auth/ntlm/auth_simple.c

index c12e233219f7c68f9aad6f7c4e3ccb332e7287fe..2dc0d8c79974bb012f3a8ac4013e77272d9833ca 100644 (file)
@@ -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,
index cd96113ca0396c5f3d56ac0dc3ba949f68606614..142bd401c9f197d73d6b8c465d1103dc7128afdf 100644 (file)
 */
 
 #include "includes.h"
+#include <tevent.h>
+#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;
+}