2 Unix SMB/CIFS implementation.
3 Samba3 database dump utility
5 Copyright (C) Jelmer Vernooij 2005
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/samba3/sam.h"
24 #include "lib/cmdline/popt_common.h"
26 static const char *libdir = "/var/lib/samba";
28 static NTSTATUS print_sam(void)
30 struct samba3_samaccount *accounts;
35 asprintf(&tdbsam_file, "%s/passdb.tdb", libdir);
37 printf("Opening TDB sam %s\n", tdbsam_file);
39 status = samba3_read_tdbsam(NULL, tdbsam_file, &accounts, &count);
40 if (NT_STATUS_IS_ERR(status)) {
41 fprintf(stderr, "Error reading tdbsam database %s\n", tdbsam_file);
45 for (i = 0; i < count; i++) {
46 printf("%d: %s\n", accounts[i].user_rid, accounts[i].username);
52 int main(int argc, char **argv)
56 struct poptOption long_options[] = {
58 { "libdir", 0, POPT_ARG_STRING, &libdir, 'l', "Set libdir [/var/lib/samba]", "LIBDIR" },
63 pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0);
65 poptSetOtherOptionHelp(pc, "<smb.conf>");
67 while((opt = poptGetNextOpt(pc)) != -1) {