s3: Fix nested get_share_mode_lock calls
[Samba/gebeck_regimport.git] / auth / common_auth.h
blob40f7da4fe7341b0fcd7f2d2de77c68b69398dc1c
1 /*
2 Unix SMB/CIFS implementation.
3 Standardised Authentication types
4 Copyright (C) Andrew Bartlett 2001-2010
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 3 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, see <http://www.gnu.org/licenses/>.
20 #ifndef AUTH_COMMON_AUTH_H
21 #define AUTH_COMMON_AUTH_H
23 #include "librpc/gen_ndr/auth.h"
25 #define USER_INFO_CASE_INSENSITIVE_USERNAME 0x01 /* username may be in any case */
26 #define USER_INFO_CASE_INSENSITIVE_PASSWORD 0x02 /* password may be in any case */
27 #define USER_INFO_DONT_CHECK_UNIX_ACCOUNT 0x04 /* don't check unix account status */
28 #define USER_INFO_INTERACTIVE_LOGON 0x08 /* don't check unix account status */
30 enum auth_password_state {
31 AUTH_PASSWORD_PLAIN = 1,
32 AUTH_PASSWORD_HASH = 2,
33 AUTH_PASSWORD_RESPONSE = 3
36 #define AUTH_SESSION_INFO_DEFAULT_GROUPS 0x01 /* Add the user to the default world and network groups */
37 #define AUTH_SESSION_INFO_AUTHENTICATED 0x02 /* Add the user to the 'authenticated users' group */
38 #define AUTH_SESSION_INFO_SIMPLE_PRIVILEGES 0x04 /* Use a trivial map between users and privilages, rather than a DB */
39 #define AUTH_SESSION_INFO_UNIX_TOKEN 0x08 /* The returned token must have the unix_token and unix_info elements provided */
41 struct auth_usersupplied_info
43 const char *workstation_name;
44 const struct tsocket_address *remote_host;
46 uint32_t logon_parameters;
48 bool mapped_state;
49 bool was_mapped;
50 /* the values the client gives us */
51 struct {
52 const char *account_name;
53 const char *domain_name;
54 } client, mapped;
56 enum auth_password_state password_state;
58 struct {
59 struct {
60 DATA_BLOB lanman;
61 DATA_BLOB nt;
62 } response;
63 struct {
64 struct samr_Password *lanman;
65 struct samr_Password *nt;
66 } hash;
68 char *plaintext;
69 } password;
70 uint32_t flags;
73 struct auth_method_context;
74 struct tevent_context;
75 struct imessaging_context;
76 struct loadparm_context;
77 struct ldb_context;
78 struct smb_krb5_context;
80 struct auth4_context {
81 struct {
82 /* Who set this up in the first place? */
83 const char *set_by;
85 bool may_be_modified;
87 DATA_BLOB data;
88 } challenge;
90 /* methods, in the order they should be called */
91 struct auth_method_context *methods;
93 /* the event context to use for calls that can block */
94 struct tevent_context *event_ctx;
96 /* the messaging context which can be used by backends */
97 struct imessaging_context *msg_ctx;
99 /* loadparm context */
100 struct loadparm_context *lp_ctx;
102 /* SAM database for this local machine - to fill in local groups, or to authenticate local NTLM users */
103 struct ldb_context *sam_ctx;
105 NTSTATUS (*check_password)(struct auth4_context *auth_ctx,
106 TALLOC_CTX *mem_ctx,
107 const struct auth_usersupplied_info *user_info,
108 struct auth_user_info_dc **user_info_dc);
110 NTSTATUS (*get_challenge)(struct auth4_context *auth_ctx, uint8_t chal[8]);
112 bool (*challenge_may_be_modified)(struct auth4_context *auth_ctx);
114 NTSTATUS (*set_challenge)(struct auth4_context *auth_ctx, const uint8_t chal[8], const char *set_by);
116 NTSTATUS (*generate_session_info)(TALLOC_CTX *mem_ctx,
117 struct auth4_context *auth_context,
118 struct auth_user_info_dc *user_info_dc,
119 uint32_t session_info_flags,
120 struct auth_session_info **session_info);
122 NTSTATUS (*generate_session_info_pac)(struct auth4_context *auth_ctx,
123 TALLOC_CTX *mem_ctx,
124 struct smb_krb5_context *smb_krb5_context,
125 DATA_BLOB *pac_blob,
126 const char *principal_name,
127 const struct tsocket_address *remote_address,
128 uint32_t session_info_flags,
129 struct auth_session_info **session_info);
132 #endif