root/source4/auth/ntlm/auth_simple.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. authenticate_username_pw

   1 /* 
   2    Unix SMB/CIFS implementation.
   3 
   4    auth functions
   5 
   6    Copyright (C) Simo Sorce 2005
   7    Copyright (C) Andrew Tridgell 2005
   8    Copyright (C) Andrew Bartlett 2005
   9    
  10    This program is free software; you can redistribute it and/or modify
  11    it under the terms of the GNU General Public License as published by
  12    the Free Software Foundation; either version 3 of the License, or
  13    (at your option) any later version.
  14    
  15    This program is distributed in the hope that it will be useful,
  16    but WITHOUT ANY WARRANTY; without even the implied warranty of
  17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18    GNU General Public License for more details.
  19    
  20    You should have received a copy of the GNU General Public License
  21    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  22 */
  23 
  24 #include "includes.h"
  25 #include "auth/auth.h"
  26 #include "lib/events/events.h"
  27 #include "param/param.h"
  28 #include "auth/session_proto.h"
  29 
  30 /*
  31  It's allowed to pass NULL as session_info,
  32  when the caller doesn't need a session_info
  33 */
  34 _PUBLIC_ NTSTATUS authenticate_username_pw(TALLOC_CTX *mem_ctx,
     /* [<][>][^][v][top][bottom][index][help] */
  35                                            struct tevent_context *ev,
  36                                            struct messaging_context *msg,
  37                                            struct loadparm_context *lp_ctx,
  38                                            const char *nt4_domain,
  39                                            const char *nt4_username,
  40                                            const char *password,
  41                                            struct auth_session_info **session_info) 
  42 {
  43         struct auth_context *auth_context;
  44         struct auth_usersupplied_info *user_info;
  45         struct auth_serversupplied_info *server_info;
  46         NTSTATUS nt_status;
  47         TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
  48 
  49         if (!tmp_ctx) {
  50                 return NT_STATUS_NO_MEMORY;
  51         }
  52 
  53         nt_status = auth_context_create(tmp_ctx, 
  54                                         ev, msg,
  55                                         lp_ctx,
  56                                         &auth_context);
  57         if (!NT_STATUS_IS_OK(nt_status)) {
  58                 talloc_free(tmp_ctx);
  59                 return nt_status;
  60         }
  61 
  62         user_info = talloc(tmp_ctx, struct auth_usersupplied_info);
  63         if (!user_info) {
  64                 talloc_free(tmp_ctx);
  65                 return NT_STATUS_NO_MEMORY;
  66         }
  67 
  68         user_info->mapped_state = true;
  69         user_info->client.account_name = nt4_username;
  70         user_info->mapped.account_name = nt4_username;
  71         user_info->client.domain_name = nt4_domain;
  72         user_info->mapped.domain_name = nt4_domain;
  73 
  74         user_info->workstation_name = NULL;
  75 
  76         user_info->remote_host = NULL;
  77 
  78         user_info->password_state = AUTH_PASSWORD_PLAIN;
  79         user_info->password.plaintext = talloc_strdup(user_info, password);
  80 
  81         user_info->flags = USER_INFO_CASE_INSENSITIVE_USERNAME |
  82                 USER_INFO_DONT_CHECK_UNIX_ACCOUNT;
  83 
  84         user_info->logon_parameters = 0;
  85 
  86         nt_status = auth_check_password(auth_context, tmp_ctx, user_info, &server_info);
  87         if (!NT_STATUS_IS_OK(nt_status)) {
  88                 talloc_free(tmp_ctx);
  89                 return nt_status;
  90         }
  91 
  92         if (session_info) {
  93                 nt_status = auth_generate_session_info(tmp_ctx, ev, lp_ctx, server_info, session_info);
  94 
  95                 if (NT_STATUS_IS_OK(nt_status)) {
  96                         talloc_steal(mem_ctx, *session_info);
  97                 }
  98         }
  99 
 100         talloc_free(tmp_ctx);
 101         return nt_status;
 102 }
 103 

/* [<][>][^][v][top][bottom][index][help] */