s3-auth: Provide helper routine to check password and return session_info
authorAndrew Bartlett <abartlet@samba.org>
Fri, 3 Feb 2012 12:32:26 +0000 (23:32 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 24 Feb 2012 00:23:18 +0000 (11:23 +1100)
source3/auth/auth_generic.c
source3/auth/proto.h

index cf6866c..43baab5 100644 (file)
@@ -346,3 +346,29 @@ NTSTATUS auth_generic_prepare(TALLOC_CTX *mem_ctx,
        TALLOC_FREE(tmp_ctx);
        return NT_STATUS_OK;
 }
+
+NTSTATUS auth_check_password_session_info(struct auth4_context *auth_context,
+                                         TALLOC_CTX *mem_ctx,
+                                         struct auth_usersupplied_info *user_info,
+                                         struct auth_session_info **session_info)
+{
+       NTSTATUS nt_status;
+       void *server_info;
+
+       nt_status = auth_context->check_ntlm_password(auth_context,
+                                                     talloc_tos(),
+                                                     user_info,
+                                                     &server_info, NULL, NULL);
+
+       if (NT_STATUS_IS_OK(nt_status)) {
+               nt_status = auth_context->generate_session_info(auth_context,
+                                                               mem_ctx,
+                                                               server_info,
+                                                               user_info->client.account_name,
+                                                               AUTH_SESSION_INFO_UNIX_TOKEN |
+                                                               AUTH_SESSION_INFO_DEFAULT_GROUPS,
+                                                               session_info);
+               TALLOC_FREE(server_info);
+       }
+       return nt_status;
+}
index 2d123b0..c68b99a 100644 (file)
@@ -73,6 +73,11 @@ NTSTATUS make_auth4_context(TALLOC_CTX *mem_ctx, struct auth4_context **auth4_co
 NTSTATUS auth_generic_prepare(TALLOC_CTX *mem_ctx, const struct tsocket_address *remote_address,
                              struct gensec_security **gensec_security_out);
 
+NTSTATUS auth_check_password_session_info(struct auth4_context *auth_context,
+                                         TALLOC_CTX *mem_ctx,
+                                         struct auth_usersupplied_info *user_info,
+                                         struct auth_session_info **session_info);
+
 /* The following definitions come from auth/auth_ntlmssp.c  */
 
 NTSTATUS auth3_generate_session_info(struct auth4_context *auth_context,