s3-net: use net_scan_dc in net rpc vampire keytab.
authorGünther Deschner <gd@samba.org>
Tue, 11 Nov 2008 18:00:26 +0000 (19:00 +0100)
committerGünther Deschner <gd@samba.org>
Tue, 18 Nov 2008 15:01:01 +0000 (16:01 +0100)
Guenther

source3/utils/net_rpc_samsync.c

index 9fab9491304eca63995331a9555fe5f18d291e76..22c6d25402430173ef4ace1eb4d82c73d2cff78d 100644 (file)
@@ -457,6 +457,9 @@ static NTSTATUS rpc_vampire_keytab_ds_internals(struct net_context *c,
 int rpc_vampire_keytab(struct net_context *c, int argc, const char **argv)
 {
        int ret = 0;
+       NTSTATUS status;
+       struct cli_state *cli = NULL;
+       struct net_dc_info dc_info;
 
        if (c->display_usage || (argc < 1)) {
                d_printf("Usage:\n"
@@ -465,14 +468,30 @@ int rpc_vampire_keytab(struct net_context *c, int argc, const char **argv)
                return 0;
        }
 
-       ret = run_rpc_command(c, NULL, &ndr_table_drsuapi.syntax_id,
-                             NET_FLAGS_SEAL,
-                             rpc_vampire_keytab_ds_internals, argc, argv);
-       if (ret == 0) {
-               return 0;
+       status = net_make_ipc_connection(c, 0, &cli);
+       if (!NT_STATUS_IS_OK(status)) {
+               return -1;
        }
 
-       return run_rpc_command(c, NULL, &ndr_table_netlogon.syntax_id, 0,
-                              rpc_vampire_keytab_internals,
-                              argc, argv);
+       status = net_scan_dc(c, cli, &dc_info);
+       if (!NT_STATUS_IS_OK(status)) {
+               return -1;
+       }
+
+       if (!dc_info.is_ad) {
+               printf("DC is not running Active Directory\n");
+               return -1;
+       }
+
+       if (dc_info.is_mixed_mode) {
+               ret = run_rpc_command(c, cli, &ndr_table_netlogon.syntax_id,
+                                     0,
+                                     rpc_vampire_keytab_internals, argc, argv);
+       } else {
+               ret = run_rpc_command(c, cli, &ndr_table_drsuapi.syntax_id,
+                                     NET_FLAGS_SEAL,
+                                     rpc_vampire_keytab_ds_internals, argc, argv);
+       }
+
+       return ret;
 }