samba-tool: refuse to demote if the current DC has still roles
[Samba/gebeck_regimport.git] / source4 / auth / gensec / gensec_util.c
blob267366af6117ad1ddcf8c619146539c64b0f4c6e
1 /*
2 Unix SMB/CIFS implementation.
4 Generic Authentication Interface
6 Copyright (C) Andrew Tridgell 2003
7 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2006
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "includes.h"
24 #include "auth/gensec/gensec.h"
25 #include "auth/auth.h"
26 #include "auth/system_session_proto.h"
28 NTSTATUS gensec_generate_session_info(TALLOC_CTX *mem_ctx,
29 struct gensec_security *gensec_security,
30 struct auth_user_info_dc *user_info_dc,
31 struct auth_session_info **session_info)
33 NTSTATUS nt_status;
34 uint32_t session_info_flags = 0;
36 if (gensec_security->want_features & GENSEC_FEATURE_UNIX_TOKEN) {
37 session_info_flags |= AUTH_SESSION_INFO_UNIX_TOKEN;
40 session_info_flags |= AUTH_SESSION_INFO_DEFAULT_GROUPS;
41 if (user_info_dc->info->authenticated) {
42 session_info_flags |= AUTH_SESSION_INFO_AUTHENTICATED;
45 if (gensec_security->auth_context) {
46 nt_status = gensec_security->auth_context->generate_session_info(mem_ctx, gensec_security->auth_context,
47 user_info_dc,
48 session_info_flags,
49 session_info);
50 } else {
51 session_info_flags |= AUTH_SESSION_INFO_SIMPLE_PRIVILEGES;
52 nt_status = auth_generate_session_info(mem_ctx,
53 NULL,
54 NULL,
55 user_info_dc, session_info_flags,
56 session_info);
58 return nt_status;