r23792: convert Samba4 to GPLv3
[garming/samba-autobuild/.git] / source4 / auth / auth_anonymous.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    Anonymous Authentification
5
6    Copyright (C) Stefan Metzmacher            2004-2005
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include "includes.h"
23 #include "auth/auth.h"
24
25 /**
26  * Return a anonymous logon for anonymous users (username = "")
27  *
28  * Typically used as the first module in the auth chain, this allows
29  * anonymou logons to be dealt with in one place.  Non-anonymou logons 'fail'
30  * and pass onto the next module.
31  **/
32 static NTSTATUS anonymous_want_check(struct auth_method_context *ctx,
33                                      TALLOC_CTX *mem_ctx,
34                                      const struct auth_usersupplied_info *user_info)
35 {
36         if (user_info->client.account_name && *user_info->client.account_name) {
37                 return NT_STATUS_NOT_IMPLEMENTED;
38         }
39
40         return NT_STATUS_OK;
41 }
42
43 /**
44  * Return a anonymous logon for anonymous users (username = "")
45  *
46  * Typically used as the first module in the auth chain, this allows
47  * anonymou logons to be dealt with in one place.  Non-anonymou logons 'fail'
48  * and pass onto the next module.
49  **/
50 static NTSTATUS anonymous_check_password(struct auth_method_context *ctx,
51                                          TALLOC_CTX *mem_ctx,
52                                          const struct auth_usersupplied_info *user_info, 
53                                          struct auth_serversupplied_info **_server_info)
54 {
55         return auth_anonymous_server_info(mem_ctx, _server_info);
56 }
57
58 static struct auth_operations anonymous_auth_ops = {
59         .name           = "anonymous",
60         .get_challenge  = auth_get_challenge_not_implemented,
61         .want_check     = anonymous_want_check,
62         .check_password = anonymous_check_password
63 };
64
65 NTSTATUS auth_anonymous_init(void)
66 {
67         NTSTATUS ret;
68
69         ret = auth_register(&anonymous_auth_ops);
70         if (!NT_STATUS_IS_OK(ret)) {
71                 DEBUG(0,("Failed to register 'anonymous' auth backend!\n"));
72                 return ret;
73         }
74
75         return ret;
76 }