s4-dsdb: Add/Update SCHEMA_SEQ_NUM key in the metadata.tdb after schemaUpdateNow
[Samba/bb.git] / auth / common_auth.h
blobcf21543a91922d1e8c82373b2732156df18fae63
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 /* Private data for the callbacks on this auth context */
106 void *private_data;
108 NTSTATUS (*check_ntlm_password)(struct auth4_context *auth_ctx,
109 TALLOC_CTX *mem_ctx,
110 const struct auth_usersupplied_info *user_info,
111 void **server_returned_info,
112 DATA_BLOB *nt_session_key, DATA_BLOB *lm_session_key);
114 NTSTATUS (*get_ntlm_challenge)(struct auth4_context *auth_ctx, uint8_t chal[8]);
116 bool (*challenge_may_be_modified)(struct auth4_context *auth_ctx);
118 NTSTATUS (*set_ntlm_challenge)(struct auth4_context *auth_ctx, const uint8_t chal[8], const char *set_by);
120 NTSTATUS (*generate_session_info)(struct auth4_context *auth_context,
121 TALLOC_CTX *mem_ctx,
122 void *server_returned_info,
123 const char *original_user_name,
124 uint32_t session_info_flags,
125 struct auth_session_info **session_info);
127 NTSTATUS (*generate_session_info_pac)(struct auth4_context *auth_ctx,
128 TALLOC_CTX *mem_ctx,
129 struct smb_krb5_context *smb_krb5_context,
130 DATA_BLOB *pac_blob,
131 const char *principal_name,
132 const struct tsocket_address *remote_address,
133 uint32_t session_info_flags,
134 struct auth_session_info **session_info);
137 #endif