r9798: Add generic functions for handling smb.conf files (the parameters don't to...
[sfrench/samba-autobuild/.git] / source4 / lib / samba3 / policy.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  account policy storage
4  *  Copyright (C) Jelmer Vernooij 2005
5  *  
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 #include "includes.h"
22 #include "lib/tdb/include/tdbutil.h"
23 #include "lib/samba3/samba3.h"
24 #include "system/filesys.h"
25
26 NTSTATUS samba3_read_account_policy(const char *fn, TALLOC_CTX *ctx, struct samba3_policy *ret)
27 {
28         TDB_CONTEXT *tdb = tdb_open(fn, 0, TDB_DEFAULT, O_RDONLY, 0600);
29         if (!tdb) {
30                 DEBUG(0,("Failed to open account policy database\n"));
31                 return NT_STATUS_UNSUCCESSFUL;
32         }
33
34         tdb_fetch_uint32(tdb, "min password length", &ret->min_password_length);
35         tdb_fetch_uint32(tdb, "password history", &ret->password_history);
36         tdb_fetch_uint32(tdb, "user must logon to change pasword", &ret->user_must_logon_to_change_password);
37         tdb_fetch_uint32(tdb, "maximum password age", &ret->maximum_password_age);
38         tdb_fetch_uint32(tdb, "minimum password age", &ret->minimum_password_age);
39         tdb_fetch_uint32(tdb, "lockout duration", &ret->lockout_duration);
40         tdb_fetch_uint32(tdb, "reset count minutes", &ret->reset_count_minutes);
41         tdb_fetch_uint32(tdb, "bad lockout minutes", &ret->bad_lockout_minutes);
42         tdb_fetch_uint32(tdb, "disconnect time", &ret->disconnect_time);
43         tdb_fetch_uint32(tdb, "refuse machine password change", &ret->refuse_machine_password_change);
44
45         /* FIXME: Read privileges as well */
46
47         tdb_close(tdb);
48
49         return NT_STATUS_OK;
50 }