2 Unix SMB/CIFS implementation.
3 Standardised Authentication types
4 Copyright (C) Andrew Bartlett 2001
5 Copyright (C) Stefan Metzmacher 2005
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 3 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, see <http://www.gnu.org/licenses/>.
24 #include "librpc/gen_ndr/ndr_krb5pac.h"
25 #include "librpc/gen_ndr/auth.h"
26 #include "../auth/common_auth.h"
28 extern const char *krbtgt_attrs
[];
29 extern const char *server_attrs
[];
30 extern const char *user_attrs
[];
32 union netr_Validation
;
33 struct netr_SamBaseInfo
;
35 struct loadparm_context
;
37 /* modules can use the following to determine if the interface has changed
38 * please increment the version number after each interface change
39 * with a comment and maybe update struct auth_critical_sizes.
41 /* version 1 - version from samba 3.0 - metze */
42 /* version 2 - initial samba4 version - metze */
43 /* version 3 - subsequent samba4 version - abartlet */
44 /* version 4 - subsequent samba4 version - metze */
45 /* version 0 - till samba4 is stable - metze */
46 #define AUTH4_INTERFACE_VERSION 0
48 struct auth_method_context
;
49 struct auth_check_password_request
;
51 struct auth_session_info
;
53 struct smb_krb5_context
;
55 struct auth_operations
{
58 /* Given the user supplied info, check if this backend want to handle the password checking */
60 NTSTATUS (*want_check
)(struct auth_method_context
*ctx
, TALLOC_CTX
*mem_ctx
,
61 const struct auth_usersupplied_info
*user_info
);
63 /* Given the user supplied info, check a password */
65 NTSTATUS (*check_password
)(struct auth_method_context
*ctx
, TALLOC_CTX
*mem_ctx
,
66 const struct auth_usersupplied_info
*user_info
,
67 struct auth_user_info_dc
**interim_info
);
69 /* Lookup a 'session info interim' return based only on the principal or DN */
70 NTSTATUS (*get_user_info_dc_principal
)(TALLOC_CTX
*mem_ctx
,
71 struct auth4_context
*auth_context
,
72 const char *principal
,
73 struct ldb_dn
*user_dn
,
74 struct auth_user_info_dc
**interim_info
);
77 struct auth_method_context
{
78 struct auth_method_context
*prev
, *next
;
79 struct auth4_context
*auth_ctx
;
80 const struct auth_operations
*ops
;
85 /* this structure is used by backends to determine the size of some critical types */
86 struct auth_critical_sizes
{
87 int interface_version
;
88 int sizeof_auth_operations
;
89 int sizeof_auth_methods
;
90 int sizeof_auth_context
;
91 int sizeof_auth_usersupplied_info
;
92 int sizeof_auth_user_info_dc
;
95 NTSTATUS
encrypt_user_info(TALLOC_CTX
*mem_ctx
, struct auth4_context
*auth_context
,
96 enum auth_password_state to_state
,
97 const struct auth_usersupplied_info
*user_info_in
,
98 const struct auth_usersupplied_info
**user_info_encrypted
);
101 #include "auth/session.h"
102 #include "auth/unix_token_proto.h"
103 #include "auth/system_session_proto.h"
104 #include "libcli/security/security.h"
108 struct gensec_security
;
109 struct cli_credentials
;
111 NTSTATUS
auth_get_challenge(struct auth4_context
*auth_ctx
, uint8_t chal
[8]);
112 NTSTATUS
authsam_account_ok(TALLOC_CTX
*mem_ctx
,
113 struct ldb_context
*sam_ctx
,
114 uint32_t logon_parameters
,
115 struct ldb_dn
*domain_dn
,
116 struct ldb_message
*msg
,
117 const char *logon_workstation
,
118 const char *name_for_logs
,
119 bool allow_domain_trust
,
120 bool password_change
);
122 struct auth_session_info
*system_session(struct loadparm_context
*lp_ctx
);
123 NTSTATUS
authsam_make_user_info_dc(TALLOC_CTX
*mem_ctx
, struct ldb_context
*sam_ctx
,
124 const char *netbios_name
,
125 const char *domain_name
,
126 struct ldb_dn
*domain_dn
,
127 struct ldb_message
*msg
,
128 DATA_BLOB user_sess_key
, DATA_BLOB lm_sess_key
,
129 struct auth_user_info_dc
**_user_info_dc
);
130 NTSTATUS
auth_system_session_info(TALLOC_CTX
*parent_ctx
,
131 struct loadparm_context
*lp_ctx
,
132 struct auth_session_info
**_session_info
) ;
134 NTSTATUS
auth_context_create_methods(TALLOC_CTX
*mem_ctx
, const char **methods
,
135 struct tevent_context
*ev
,
136 struct imessaging_context
*msg
,
137 struct loadparm_context
*lp_ctx
,
138 struct ldb_context
*sam_ctx
,
139 struct auth4_context
**auth_ctx
);
140 const char **auth_methods_from_lp(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
);
142 NTSTATUS
auth_context_create(TALLOC_CTX
*mem_ctx
,
143 struct tevent_context
*ev
,
144 struct imessaging_context
*msg
,
145 struct loadparm_context
*lp_ctx
,
146 struct auth4_context
**auth_ctx
);
148 NTSTATUS
auth_check_password_wrapper(struct auth4_context
*auth_ctx
,
150 const struct auth_usersupplied_info
*user_info
,
151 void **server_returned_info
,
152 DATA_BLOB
*user_session_key
, DATA_BLOB
*lm_session_key
);
154 NTSTATUS
auth_check_password(struct auth4_context
*auth_ctx
,
156 const struct auth_usersupplied_info
*user_info
,
157 struct auth_user_info_dc
**user_info_dc
);
158 NTSTATUS
auth4_init(void);
159 NTSTATUS
auth_register(const struct auth_operations
*ops
);
160 NTSTATUS
server_service_auth_init(void);
161 NTSTATUS
authenticate_username_pw(TALLOC_CTX
*mem_ctx
,
162 struct tevent_context
*ev
,
163 struct imessaging_context
*msg
,
164 struct loadparm_context
*lp_ctx
,
165 const char *nt4_domain
,
166 const char *nt4_username
,
167 const char *password
,
168 const uint32_t logon_parameters
,
169 struct auth_session_info
**session_info
);
171 struct tevent_req
*auth_check_password_send(TALLOC_CTX
*mem_ctx
,
172 struct tevent_context
*ev
,
173 struct auth4_context
*auth_ctx
,
174 const struct auth_usersupplied_info
*user_info
);
175 NTSTATUS
auth_check_password_recv(struct tevent_req
*req
,
177 struct auth_user_info_dc
**user_info_dc
);
179 bool auth_challenge_may_be_modified(struct auth4_context
*auth_ctx
);
180 NTSTATUS
auth_context_set_challenge(struct auth4_context
*auth_ctx
, const uint8_t chal
[8], const char *set_by
);
182 NTSTATUS
auth_get_user_info_dc_principal(TALLOC_CTX
*mem_ctx
,
183 struct auth4_context
*auth_ctx
,
184 const char *principal
,
185 struct ldb_dn
*user_dn
,
186 struct auth_user_info_dc
**user_info_dc
);
188 NTSTATUS
samba_server_gensec_start(TALLOC_CTX
*mem_ctx
,
189 struct tevent_context
*event_ctx
,
190 struct imessaging_context
*msg_ctx
,
191 struct loadparm_context
*lp_ctx
,
192 struct cli_credentials
*server_credentials
,
193 const char *target_service
,
194 struct gensec_security
**gensec_context
);
196 #endif /* _SMBAUTH_H_ */