2 Unix SMB/CIFS implementation.
3 Generic authenticaion types
4 Copyright (C) Andrew Bartlett 2001
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 * Return a guest logon for guest users (username = "")
26 * Typically used as the first module in the auth chain, this allows
27 * guest logons to be delt with in one place. Non-gust logons 'fail'
28 * and pass onto the next module.
31 static NTSTATUS check_guest_security(const struct auth_context *auth_context,
32 void *my_private_data,
34 const auth_usersupplied_info *user_info,
35 auth_serversupplied_info **server_info)
37 NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE;
39 if (!(user_info->internal_username.str
40 && *user_info->internal_username.str)) {
41 if (make_server_info_guest(server_info)) {
42 nt_status = NT_STATUS_OK;
44 nt_status = NT_STATUS_NO_SUCH_USER;
51 /* Guest modules initialisation */
52 BOOL auth_init_guest(struct auth_context *auth_context, auth_methods **auth_method)
54 if (!make_auth_methods(auth_context, auth_method)) {
58 (*auth_method)->auth = check_guest_security;
63 * Return an error based on username
65 * This function allows the testing of obsure errors, as well as the generation
66 * of NT_STATUS -> DOS error mapping tables.
68 * This module is of no value to end-users.
70 * The password is ignored.
72 * @return An NTSTATUS value based on the username
75 static NTSTATUS check_name_to_ntstatus_security(const struct auth_context *auth_context,
76 void *my_private_data,
78 const auth_usersupplied_info *user_info,
79 auth_serversupplied_info **server_info)
84 fstrcpy(user, user_info->smb_name.str);
86 if (strncasecmp("NT_STATUS", user, strlen("NT_STATUS")) == 0) {
88 return nt_status_string_to_code(user);
92 error_num = strtoul(user, NULL, 16);
94 DEBUG(5,("Error for user %s was %lx\n", user, error_num));
96 nt_status = NT_STATUS(error_num);
101 /** Module initailisation function */
102 BOOL auth_init_name_to_ntstatus(struct auth_context *auth_context, auth_methods **auth_method)
104 if (!make_auth_methods(auth_context, auth_method)) {
108 (*auth_method)->auth = check_name_to_ntstatus_security;