2 * Unix SMB/CIFS implementation.
3 * account policy storage
4 * Copyright (C) Jean François Micouleau 1998-2001.
5 * Copyright (C) Andrew Bartlett 2002
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "lib/tdb/include/tdbutil.h"
24 #include "lib/samba3/samba3.h"
25 #include "system/filesys.h"
27 #define DATABASE_VERSION 2
29 /****************************************************************************
30 Open the account policy tdb.
31 ****************************************************************************/
33 NTSTATUS samba3_read_account_policy(const char *fn, TALLOC_CTX *ctx, struct samba3_policy *ret)
35 const char *vstring = "INFO/version";
38 TDB_CONTEXT *tdb = tdb_open(fn, 0, TDB_DEFAULT, O_RDONLY, 0600);
40 DEBUG(0,("Failed to open account policy database\n"));
41 return NT_STATUS_UNSUCCESSFUL;
44 /* handle a Samba upgrade */
45 if (!tdb_fetch_uint32(tdb, vstring, &version) || version != DATABASE_VERSION) {
46 tdb_store_uint32(tdb, vstring, DATABASE_VERSION);
49 ret = talloc_zero(ctx, struct samba3_policy);
51 tdb_fetch_uint32(tdb, "min password length", &ret->min_password_length);
52 tdb_fetch_uint32(tdb, "password history", &ret->password_history);
53 tdb_fetch_uint32(tdb, "user must logon to change pasword", &ret->user_must_logon_to_change_password);
54 tdb_fetch_uint32(tdb, "maximum password age", &ret->maximum_password_age);
55 tdb_fetch_uint32(tdb, "minimum password age", &ret->minimum_password_age);
56 tdb_fetch_uint32(tdb, "lockout duration", &ret->lockout_duration);
57 tdb_fetch_uint32(tdb, "reset count minutes", &ret->reset_count_minutes);
58 tdb_fetch_uint32(tdb, "bad lockout minutes", &ret->bad_lockout_minutes);
59 tdb_fetch_uint32(tdb, "disconnect time", &ret->disconnect_time);
60 tdb_fetch_uint32(tdb, "refuse machine password change", &ret->refuse_machine_password_change);
62 /* FIXME: Read privileges as well */