source: vendor/3.6.0/source4/samba_tool/vampire.c

Last change on this file was 740, checked in by Silvan Scherrer, 13 years ago

Samba Server: update vendor to 3.6.0

File size: 3.3 KB
Line 
1/*
2 Samba Unix/Linux SMB client library
3 Distributed SMB/CIFS Server Management Utility
4
5 Copyright (C) 2004 Stefan Metzmacher <metze@samba.org>
6 Copyright (C) 2005 Andrew Bartlett <abartlet@samba.org>
7
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.
12
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.
17
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/>.
20*/
21
22#include "includes.h"
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"
30
31/* main function table */
32static const struct net_functable net_samdump_functable[] = {
33 {NULL, NULL, NULL, NULL}
34};
35
36int net_samdump(struct net_context *ctx, int argc, const char **argv)
37{
38 NTSTATUS status;
39 struct libnet_context *libnetctx;
40 struct libnet_SamDump r;
41 int rc;
42
43 switch (argc) {
44 case 0:
45 break;
46 case 1:
47 default:
48 rc = net_run_function(ctx, argc, argv, net_samdump_functable,
49 net_samdump_usage);
50 return rc;
51 }
52
53 libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
54 if (!libnetctx) {
55 return -1;
56 }
57 libnetctx->cred = ctx->credentials;
58
59 r.out.error_string = NULL;
60 r.in.machine_account = NULL;
61 r.in.binding_string = NULL;
62
63 status = libnet_SamDump(libnetctx, ctx, &r);
64 if (!NT_STATUS_IS_OK(status)) {
65 DEBUG(0,("libnet_SamDump returned %s: %s\n",
66 nt_errstr(status),
67 r.out.error_string));
68 return -1;
69 }
70
71 talloc_free(libnetctx);
72
73 return 0;
74}
75
76int net_samdump_usage(struct net_context *ctx, int argc, const char **argv)
77{
78 d_printf("samba-tool samdump\n");
79 return 0;
80}
81
82int net_samdump_help(struct net_context *ctx, int argc, const char **argv)
83{
84 d_printf("Dumps the sam of the domain we are joined to.\n");
85 return 0;
86}
87
88int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv)
89{
90 NTSTATUS status;
91 struct libnet_context *libnetctx;
92 struct libnet_samsync_ldb r;
93
94 libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
95 if (!libnetctx) {
96 return -1;
97 }
98 libnetctx->cred = ctx->credentials;
99
100 r.out.error_string = NULL;
101 r.in.machine_account = NULL;
102 r.in.binding_string = NULL;
103
104 /* Needed to override the ACLs on ldb */
105 r.in.session_info = system_session(ctx->lp_ctx);
106
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",
110 nt_errstr(status),
111 r.out.error_string));
112 return -1;
113 }
114
115 talloc_free(libnetctx);
116
117 return 0;
118}
119
120int net_samsync_ldb_usage(struct net_context *ctx, int argc, const char **argv)
121{
122 d_printf("samba-tool samsync\n");
123 return 0;
124}
125
126int net_samsync_ldb_help(struct net_context *ctx, int argc, const char **argv)
127{
128 d_printf("Synchronise into the local ldb the SAM of a domain.\n");
129 return 0;
130}
Note: See TracBrowser for help on using the repository browser.