2 Unix SMB/CIFS implementation.
4 Generic Authentication Interface for Samba Servers
6 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2009
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.
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.
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/>.
22 /* This code sets up GENSEC in the way that all Samba servers want
23 * (becaue they have presumed access to the sam.ldb etc */
26 #include "auth/auth.h"
27 #include "auth/gensec/gensec.h"
28 #include "param/param.h"
30 NTSTATUS
samba_server_gensec_start(TALLOC_CTX
*mem_ctx
,
31 struct tevent_context
*event_ctx
,
32 struct imessaging_context
*msg_ctx
,
33 struct loadparm_context
*lp_ctx
,
34 struct cli_credentials
*server_credentials
,
35 const char *target_service
,
36 struct gensec_security
**gensec_context
)
39 struct gensec_security
*gensec_ctx
;
40 struct auth4_context
*auth_context
;
42 TALLOC_CTX
*tmp_ctx
= talloc_new(mem_ctx
);
44 return NT_STATUS_NO_MEMORY
;
47 nt_status
= auth_context_create(tmp_ctx
,
53 if (!NT_STATUS_IS_OK(nt_status
)) {
54 DEBUG(1, ("Failed to start auth server code: %s\n", nt_errstr(nt_status
)));
59 nt_status
= gensec_server_start(tmp_ctx
,
61 lpcfg_gensec_settings(mem_ctx
, lp_ctx
),
64 if (!NT_STATUS_IS_OK(nt_status
)) {
66 DEBUG(1, ("Failed to start GENSEC server code: %s\n", nt_errstr(nt_status
)));
70 gensec_set_credentials(gensec_ctx
, server_credentials
);
73 gensec_set_target_service(gensec_ctx
, target_service
);
75 *gensec_context
= talloc_steal(mem_ctx
, gensec_ctx
);