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
;
50 struct auth_session_info
;
52 struct smb_krb5_context
;
54 struct auth_operations
{
57 /* Given the user supplied info, check if this backend want to handle the password checking */
59 NTSTATUS (*want_check
)(struct auth_method_context
*ctx
, TALLOC_CTX
*mem_ctx
,
60 const struct auth_usersupplied_info
*user_info
);
62 /* Given the user supplied info, check a password */
64 NTSTATUS (*check_password
)(struct auth_method_context
*ctx
, TALLOC_CTX
*mem_ctx
,
65 const struct auth_usersupplied_info
*user_info
,
66 struct auth_user_info_dc
**interim_info
,
68 struct tevent_req
*(*check_password_send
)(TALLOC_CTX
*mem_ctx
,
69 struct tevent_context
*ev
,
70 struct auth_method_context
*ctx
,
71 const struct auth_usersupplied_info
*user_info
);
72 NTSTATUS (*check_password_recv
)(struct tevent_req
*subreq
,
74 struct auth_user_info_dc
**interim_info
,
77 /* Lookup a 'session info interim' return based only on the principal or DN */
78 NTSTATUS (*get_user_info_dc_principal
)(TALLOC_CTX
*mem_ctx
,
79 struct auth4_context
*auth_context
,
80 const char *principal
,
81 struct ldb_dn
*user_dn
,
82 struct auth_user_info_dc
**interim_info
);
86 struct auth_method_context
{
87 struct auth_method_context
*prev
, *next
;
88 struct auth4_context
*auth_ctx
;
89 const struct auth_operations
*ops
;
94 /* this structure is used by backends to determine the size of some critical types */
95 struct auth_critical_sizes
{
96 int interface_version
;
97 int sizeof_auth_operations
;
98 int sizeof_auth_methods
;
99 int sizeof_auth_context
;
100 int sizeof_auth_usersupplied_info
;
101 int sizeof_auth_user_info_dc
;
104 NTSTATUS
encrypt_user_info(TALLOC_CTX
*mem_ctx
, struct auth4_context
*auth_context
,
105 enum auth_password_state to_state
,
106 const struct auth_usersupplied_info
*user_info_in
,
107 const struct auth_usersupplied_info
**user_info_encrypted
);
109 #include "auth/session.h"
110 #include "auth/unix_token_proto.h"
111 #include "auth/system_session_proto.h"
112 #include "libcli/security/security.h"
116 struct gensec_security
;
117 struct cli_credentials
;
119 NTSTATUS
auth_get_challenge(struct auth4_context
*auth_ctx
, uint8_t chal
[8]);
120 NTSTATUS
authsam_account_ok(TALLOC_CTX
*mem_ctx
,
121 struct ldb_context
*sam_ctx
,
122 uint32_t logon_parameters
,
123 struct ldb_dn
*domain_dn
,
124 struct ldb_message
*msg
,
125 const char *logon_workstation
,
126 const char *name_for_logs
,
127 bool allow_domain_trust
,
128 bool password_change
);
130 struct auth_session_info
*system_session(struct loadparm_context
*lp_ctx
);
131 NTSTATUS
authsam_make_user_info_dc(TALLOC_CTX
*mem_ctx
, struct ldb_context
*sam_ctx
,
132 const char *netbios_name
,
133 const char *domain_name
,
134 const char *dns_domain_name
,
135 struct ldb_dn
*domain_dn
,
136 struct ldb_message
*msg
,
137 DATA_BLOB user_sess_key
, DATA_BLOB lm_sess_key
,
138 struct auth_user_info_dc
**_user_info_dc
);
139 NTSTATUS
authsam_update_user_info_dc(TALLOC_CTX
*mem_ctx
,
140 struct ldb_context
*sam_ctx
,
141 struct auth_user_info_dc
*user_info_dc
);
142 NTSTATUS
auth_system_session_info(TALLOC_CTX
*parent_ctx
,
143 struct loadparm_context
*lp_ctx
,
144 struct auth_session_info
**_session_info
) ;
146 NTSTATUS
auth_context_create_methods(TALLOC_CTX
*mem_ctx
, const char * const *methods
,
147 struct tevent_context
*ev
,
148 struct imessaging_context
*msg
,
149 struct loadparm_context
*lp_ctx
,
150 struct ldb_context
*sam_ctx
,
151 struct auth4_context
**auth_ctx
);
152 const char **auth_methods_from_lp(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
);
154 NTSTATUS
auth_context_create(TALLOC_CTX
*mem_ctx
,
155 struct tevent_context
*ev
,
156 struct imessaging_context
*msg
,
157 struct loadparm_context
*lp_ctx
,
158 struct auth4_context
**auth_ctx
);
159 NTSTATUS
auth_context_create_for_netlogon(TALLOC_CTX
*mem_ctx
,
160 struct tevent_context
*ev
,
161 struct imessaging_context
*msg
,
162 struct loadparm_context
*lp_ctx
,
163 struct auth4_context
**auth_ctx
);
165 NTSTATUS
auth_check_password(struct auth4_context
*auth_ctx
,
167 const struct auth_usersupplied_info
*user_info
,
168 struct auth_user_info_dc
**user_info_dc
,
169 uint8_t *pauthoritative
);
170 NTSTATUS
auth4_init(void);
171 NTSTATUS
auth_register(TALLOC_CTX
*mem_ctx
, const struct auth_operations
*ops
);
172 NTSTATUS
server_service_auth_init(TALLOC_CTX
*ctx
);
173 struct tevent_req
*authenticate_ldap_simple_bind_send(TALLOC_CTX
*mem_ctx
,
174 struct tevent_context
*ev
,
175 struct imessaging_context
*msg
,
176 struct loadparm_context
*lp_ctx
,
177 struct tsocket_address
*remote_address
,
178 struct tsocket_address
*local_address
,
181 const char *password
);
182 NTSTATUS
authenticate_ldap_simple_bind_recv(struct tevent_req
*req
,
184 struct auth_session_info
**session_info
);
185 NTSTATUS
authenticate_ldap_simple_bind(TALLOC_CTX
*mem_ctx
,
186 struct tevent_context
*ev
,
187 struct imessaging_context
*msg
,
188 struct loadparm_context
*lp_ctx
,
189 struct tsocket_address
*remote_address
,
190 struct tsocket_address
*local_address
,
193 const char *password
,
194 struct auth_session_info
**session_info
);
196 struct tevent_req
*auth_check_password_send(TALLOC_CTX
*mem_ctx
,
197 struct tevent_context
*ev
,
198 struct auth4_context
*auth_ctx
,
199 const struct auth_usersupplied_info
*user_info
);
200 NTSTATUS
auth_check_password_recv(struct tevent_req
*req
,
202 struct auth_user_info_dc
**user_info_dc
,
203 uint8_t *pauthoritative
);
205 NTSTATUS
auth_context_set_challenge(struct auth4_context
*auth_ctx
, const uint8_t chal
[8], const char *set_by
);
207 NTSTATUS
samba_server_gensec_start(TALLOC_CTX
*mem_ctx
,
208 struct tevent_context
*event_ctx
,
209 struct imessaging_context
*msg_ctx
,
210 struct loadparm_context
*lp_ctx
,
211 struct cli_credentials
*server_credentials
,
212 const char *target_service
,
213 struct gensec_security
**gensec_context
);
214 NTSTATUS
samba_server_gensec_krb5_start(TALLOC_CTX
*mem_ctx
,
215 struct tevent_context
*event_ctx
,
216 struct imessaging_context
*msg_ctx
,
217 struct loadparm_context
*lp_ctx
,
218 struct cli_credentials
*server_credentials
,
219 const char *target_service
,
220 struct gensec_security
**gensec_context
);
222 #endif /* _SMBAUTH_H_ */