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 "utils/net/net.h"
24 #include "libnet/libnet.h"
25 #include "param/param.h"
27 static int net_export_keytab_usage(struct net_context *ctx, int argc, const char **argv)
29 d_printf("net export keytab <keytab>\n");
33 static int net_export_keytab_help(struct net_context *ctx, int argc, const char **argv)
35 d_printf("Dumps kerberos keys of the domain into a keytab.\n");
39 static int net_export_keytab(struct net_context *ctx, int argc, const char **argv)
42 struct libnet_context *libnetctx;
43 struct libnet_export_keytab r;
47 return net_export_keytab_usage(ctx, argc, argv);
50 r.in.keytab_name = argv[0];
54 libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
58 libnetctx->cred = ctx->credentials;
60 r.out.error_string = NULL;
62 status = libnet_export_keytab(libnetctx, ctx, &r);
63 if (!NT_STATUS_IS_OK(status)) {
64 DEBUG(0,("libnet_export_keytab returned %s: %s\n",
70 talloc_free(libnetctx);
75 /* main function table */
76 static const struct net_functable net_export_functable[] = {
77 {"keytab", "dump keys into a keytab\n", net_export_keytab, net_export_keytab_usage},
78 {NULL, NULL, NULL, NULL}
81 int net_export(struct net_context *ctx, int argc, const char **argv)
87 rc = net_export_usage(ctx, argc, argv);
91 rc = net_run_function(ctx, argc, argv, net_export_functable,
99 int net_export_usage(struct net_context *ctx, int argc, const char **argv)
101 d_printf("net export keytab <keytab>\n");
105 int net_export_help(struct net_context *ctx, int argc, const char **argv)
107 d_printf("Dumps the sam of the domain we are joined to.\n");