2 Unix SMB/Netbios implementation.
4 Generic authenticaion types
5 Copyright (C) Andrew Bartlett 2001
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 /****************************************************************************
25 Check for a guest logon (username = "") and if so create the required
27 ****************************************************************************/
29 static NTSTATUS check_guest_security(void *my_private_data,
30 const auth_usersupplied_info *user_info,
31 const auth_authsupplied_info *auth_info,
32 auth_serversupplied_info **server_info)
34 NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE;
36 if (!(user_info->internal_username.str
37 && *user_info->internal_username.str)) {
38 if (make_server_info_guest(server_info)) {
39 nt_status = NT_STATUS_OK;
41 nt_status = NT_STATUS_NO_SUCH_USER;
48 BOOL auth_init_guest(auth_methods **auth_method)
50 if (!make_auth_methods(auth_method)) {
54 (*auth_method)->auth = check_guest_security;
58 /****************************************************************************
59 Check against either sam or unix, depending on encryption.
60 ****************************************************************************/
62 static NTSTATUS check_local_security(void *my_private_data,
63 const auth_usersupplied_info *user_info,
64 const auth_authsupplied_info *auth_info,
65 auth_serversupplied_info **server_info)
67 NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE;
69 if (user_info->encrypted) {
70 nt_status = check_sam_security(my_private_data, user_info, auth_info, server_info);
72 nt_status = check_unix_security(my_private_data, user_info, auth_info, server_info);
78 BOOL auth_init_local(auth_methods **auth_method)
80 if (!make_auth_methods(auth_method)) {
84 (*auth_method)->auth = check_local_security;
88 /****************************************************************************
89 Return an error based on username
90 ****************************************************************************/
92 static NTSTATUS check_name_to_ntstatus_security(void *my_private_data,
93 const auth_usersupplied_info *user_info,
94 const auth_authsupplied_info *auth_info,
95 auth_serversupplied_info **server_info)
100 fstrcpy(user, user_info->smb_name.str);
102 error_num = strtoul(user, NULL, 16);
104 DEBUG(5,("Error for user %s was %lx\n", user, error_num));
106 nt_status = NT_STATUS(error_num);
111 BOOL auth_init_name_to_ntstatus(auth_methods **auth_method)
113 if (!make_auth_methods(auth_method)) {
117 (*auth_method)->auth = check_name_to_ntstatus_security;