2 Samba Unix/Linux SMB client library
3 Distributed SMB/CIFS Server Management Utility
5 Copyright (C) 2004 Stefan Metzmacher <metze@samba.org>
6 Copyright (C) 2005 Andrew Bartlett <abartlet@samba.org>
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/>.
23 #include "samba_tool/samba_tool.h"
24 #include "libnet/libnet.h"
25 #include "librpc/gen_ndr/samr.h"
26 #include "auth/auth.h"
27 #include "libcli/security/security.h"
28 #include "param/param.h"
29 #include "lib/events/events.h"
31 /* main function table */
32 static const struct net_functable net_samdump_functable
[] = {
33 {NULL
, NULL
, NULL
, NULL
}
36 int net_samdump(struct net_context
*ctx
, int argc
, const char **argv
)
39 struct libnet_context
*libnetctx
;
40 struct libnet_SamDump r
;
48 rc
= net_run_function(ctx
, argc
, argv
, net_samdump_functable
,
53 libnetctx
= libnet_context_init(ctx
->event_ctx
, ctx
->lp_ctx
);
57 libnetctx
->cred
= ctx
->credentials
;
59 r
.out
.error_string
= NULL
;
60 r
.in
.machine_account
= NULL
;
61 r
.in
.binding_string
= NULL
;
63 status
= libnet_SamDump(libnetctx
, ctx
, &r
);
64 if (!NT_STATUS_IS_OK(status
)) {
65 DEBUG(0,("libnet_SamDump returned %s: %s\n",
71 talloc_free(libnetctx
);
76 int net_samdump_usage(struct net_context
*ctx
, int argc
, const char **argv
)
78 d_printf("samba-tool samdump\n");
82 int net_samdump_help(struct net_context
*ctx
, int argc
, const char **argv
)
84 d_printf("Dumps the sam of the domain we are joined to.\n");
88 int net_samsync_ldb(struct net_context
*ctx
, int argc
, const char **argv
)
91 struct libnet_context
*libnetctx
;
92 struct libnet_samsync_ldb r
;
94 libnetctx
= libnet_context_init(ctx
->event_ctx
, ctx
->lp_ctx
);
98 libnetctx
->cred
= ctx
->credentials
;
100 r
.out
.error_string
= NULL
;
101 r
.in
.machine_account
= NULL
;
102 r
.in
.binding_string
= NULL
;
104 /* Needed to override the ACLs on ldb */
105 r
.in
.session_info
= system_session(ctx
->lp_ctx
);
107 status
= libnet_samsync_ldb(libnetctx
, libnetctx
, &r
);
108 if (!NT_STATUS_IS_OK(status
)) {
109 DEBUG(0,("libnet_samsync_ldb returned %s: %s\n",
111 r
.out
.error_string
));
115 talloc_free(libnetctx
);
120 int net_samsync_ldb_usage(struct net_context
*ctx
, int argc
, const char **argv
)
122 d_printf("samba-tool samsync\n");
126 int net_samsync_ldb_help(struct net_context
*ctx
, int argc
, const char **argv
)
128 d_printf("Synchronise into the local ldb the SAM of a domain.\n");