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 messaging_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 auth_context
*auth_context
;
42 nt_status
= auth_context_create(mem_ctx
,
48 if (!NT_STATUS_IS_OK(nt_status
)) {
49 DEBUG(1, ("Failed to start auth server code: %s\n", nt_errstr(nt_status
)));
53 nt_status
= gensec_server_start(mem_ctx
,
55 lp_gensec_settings(mem_ctx
, lp_ctx
),
58 if (!NT_STATUS_IS_OK(nt_status
)) {
59 talloc_free(auth_context
);
60 DEBUG(1, ("Failed to start GENSEC server code: %s\n", nt_errstr(nt_status
)));
64 talloc_steal(gensec_ctx
, auth_context
);
66 gensec_set_credentials(gensec_ctx
, server_credentials
);
69 gensec_set_target_service(gensec_ctx
, target_service
);
71 *gensec_context
= gensec_ctx
;