84a860ee6aa75787c311a90c578b732009fc6dee
[ira/wip.git] / source3 / passdb / secrets_schannel.c
1 /*
2    Unix SMB/CIFS implementation.
3    Copyright (C) Guenther Deschner    2009
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "includes.h"
20 #include "../libcli/auth/libcli_auth.h"
21 #include "../libcli/auth/schannel_state.h"
22
23 /******************************************************************************
24  Wrapper around schannel_fetch_session_key_tdb()
25  Note we must be root here.
26 *******************************************************************************/
27
28 NTSTATUS schannel_fetch_session_key(TALLOC_CTX *mem_ctx,
29                                     const char *computer_name,
30                                     struct netlogon_creds_CredentialState **pcreds)
31 {
32         struct tdb_context *tdb;
33         NTSTATUS status;
34
35         tdb = open_schannel_session_store(mem_ctx);
36         if (!tdb) {
37                 return NT_STATUS_ACCESS_DENIED;
38         }
39
40         status = schannel_fetch_session_key_tdb(tdb, mem_ctx, computer_name, pcreds);
41
42         tdb_close(tdb);
43
44         return status;
45 }
46
47 /******************************************************************************
48  Wrapper around schannel_store_session_key_tdb()
49  Note we must be root here.
50 *******************************************************************************/
51
52 NTSTATUS schannel_store_session_key(TALLOC_CTX *mem_ctx,
53                                     struct netlogon_creds_CredentialState *creds)
54 {
55         struct tdb_context *tdb;
56         NTSTATUS status;
57
58         tdb = open_schannel_session_store(mem_ctx);
59         if (!tdb) {
60                 return NT_STATUS_ACCESS_DENIED;
61         }
62
63         status = schannel_store_session_key_tdb(tdb, mem_ctx, creds);
64
65         tdb_close(tdb);
66
67         return status;
68 }