s4:gensec Use an index on computerName in schannel.ldb
[Samba/cd1.git] / source4 / auth / gensec / schannel_state.c
blobe90b73b69fcaee85b419251554321101a16d8ed1
1 /*
2 Unix SMB/CIFS implementation.
4 module to store/fetch session keys for the schannel server
6 Copyright (C) Andrew Tridgell 2004
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 #include "includes.h"
23 #include "lib/ldb/include/ldb.h"
24 #include "ldb_wrap.h"
25 #include "../lib/util/util_ldb.h"
26 #include "auth/auth.h"
27 #include "param/param.h"
29 /**
30 connect to the schannel ldb
32 struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx,
33 struct loadparm_context *lp_ctx)
35 char *path;
36 struct ldb_context *ldb;
37 bool existed;
38 const char *init_ldif =
39 "dn: @ATTRIBUTES\n" \
40 "computerName: CASE_INSENSITIVE\n" \
41 "flatname: CASE_INSENSITIVE\n" \
42 "\n" \
43 "dn: @INDEXLIST\n" \
44 "@IDXATTR: computerName\n\n";
46 path = private_path(mem_ctx, lp_ctx, "schannel.ldb");
47 if (!path) {
48 return NULL;
51 existed = file_exist(path);
53 ldb = ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, path,
54 system_session(lp_ctx),
55 NULL, LDB_FLG_NOSYNC);
56 talloc_free(path);
57 if (!ldb) {
58 return NULL;
61 if (!existed) {
62 gendb_add_ldif(ldb, init_ldif);
65 return ldb;