5a17544e82ec8519c1a1791759441454b5340807
[kai/samba.git] / source4 / utils / net / net_vampire.c
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 2 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, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24 #include "utils/net/net.h"
25 #include "libnet/libnet.h"
26 #include "librpc/gen_ndr/ndr_samr.h"
27
28 int net_samdump(struct net_context *ctx, int argc, const char **argv) 
29 {
30         NTSTATUS status;
31         struct libnet_context *libnetctx;
32         union libnet_SamDump r;
33
34         libnetctx = libnet_context_init();
35         if (!libnetctx) {
36                 return -1;      
37         }
38         libnetctx->cred = ctx->credentials;
39
40         /* prepare password change */
41         r.generic.level        = LIBNET_SAMDUMP_GENERIC;
42         r.generic.error_string = NULL;
43
44         /* do the domain join */
45         status = libnet_SamDump(libnetctx, ctx->mem_ctx, &r);
46         if (!NT_STATUS_IS_OK(status)) {
47                 DEBUG(0,("libnet_SamDump returned %s: %s\n",
48                          nt_errstr(status),
49                          r.generic.error_string));
50                 return -1;
51         }
52
53         libnet_context_destroy(&libnetctx);
54
55         return 0;
56 }
57
58 int net_samdump_usage(struct net_context *ctx, int argc, const char **argv)
59 {
60         d_printf("net samdump\n");
61         return 0;       
62 }
63
64 int net_samdump_help(struct net_context *ctx, int argc, const char **argv)
65 {
66         d_printf("Dumps the sam of the domain we are joined to.\n");
67         return 0;       
68 }