tevent: Added a description for tevent queue.
[Samba/ekacnet.git] / source4 / auth / session.c
blob03d1c91054be77d76165f7c5105d3704e0a255d2
1 /*
2 Unix SMB/CIFS implementation.
3 Authentication utility functions
4 Copyright (C) Andrew Tridgell 1992-1998
5 Copyright (C) Andrew Bartlett 2001-2010
6 Copyright (C) Jeremy Allison 2000-2001
7 Copyright (C) Rafal Szczesniak 2002
8 Copyright (C) Stefan Metzmacher 2005
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "includes.h"
25 #include "auth/auth.h"
26 #include "libcli/security/security.h"
27 #include "libcli/auth/libcli_auth.h"
28 #include "dsdb/samdb/samdb.h"
29 #include "auth/credentials/credentials.h"
30 #include "param/param.h"
31 #include "auth/session_proto.h"
33 _PUBLIC_ struct auth_session_info *anonymous_session(TALLOC_CTX *mem_ctx,
34 struct loadparm_context *lp_ctx)
36 NTSTATUS nt_status;
37 struct auth_session_info *session_info = NULL;
38 nt_status = auth_anonymous_session_info(mem_ctx, lp_ctx, &session_info);
39 if (!NT_STATUS_IS_OK(nt_status)) {
40 return NULL;
42 return session_info;
45 _PUBLIC_ NTSTATUS auth_generate_session_info(TALLOC_CTX *mem_ctx,
46 struct auth_context *auth_context,
47 struct auth_serversupplied_info *server_info,
48 struct auth_session_info **_session_info)
50 struct auth_session_info *session_info;
51 NTSTATUS nt_status;
53 session_info = talloc(mem_ctx, struct auth_session_info);
54 NT_STATUS_HAVE_NO_MEMORY(session_info);
56 session_info->server_info = talloc_reference(session_info, server_info);
58 /* unless set otherwise, the session key is the user session
59 * key from the auth subsystem */
60 session_info->session_key = server_info->user_session_key;
62 nt_status = security_token_create(session_info,
63 auth_context->event_ctx,
64 auth_context->lp_ctx,
65 server_info->account_sid,
66 server_info->primary_group_sid,
67 server_info->n_domain_groups,
68 server_info->domain_groups,
69 server_info->authenticated,
70 &session_info->security_token);
71 NT_STATUS_NOT_OK_RETURN(nt_status);
73 session_info->credentials = NULL;
75 *_session_info = session_info;
76 return NT_STATUS_OK;
79 /**
80 * prints a struct auth_session_info security token to debug output.
82 void auth_session_info_debug(int dbg_lev,
83 const struct auth_session_info *session_info)
85 if (!session_info) {
86 DEBUG(dbg_lev, ("Session Info: (NULL)\n"));
87 return;
90 security_token_debug(dbg_lev, session_info->security_token);