net: Use NetUserAdd for "net rpc user add".
authorGünther Deschner <gd@samba.org>
Wed, 16 Apr 2008 00:41:52 +0000 (02:41 +0200)
committerGünther Deschner <gd@samba.org>
Wed, 16 Apr 2008 00:41:52 +0000 (02:41 +0200)
Guenther
(This used to be commit 4868b4ea1a18d4218330c49bf57818c4b5117d1d)

source3/utils/net_rpc.c

index 3cd72fa3d85e4ec924533940c5c16f60363f7965..d0e04873721170af7126c0c6281f8d4e389cf6c3 100644 (file)
@@ -730,8 +730,34 @@ static NTSTATUS rpc_user_add_internals(const DOM_SID *domain_sid,
 
 static int rpc_user_add(int argc, const char **argv) 
 {
-       return run_rpc_command(NULL, PI_SAMR, 0, rpc_user_add_internals,
-                              argc, argv);
+       NET_API_STATUS status;
+       struct USER_INFO_1 info1;
+       uint32_t parm_error = 0;
+
+       if (argc < 1) {
+               d_printf("User must be specified\n");
+               rpc_user_usage(argc, argv);
+               return 0;
+       }
+
+       ZERO_STRUCT(info1);
+
+       info1.usri1_name = argv[0];
+       if (argc == 2) {
+               info1.usri1_password = argv[1];
+       }
+
+       status = NetUserAdd(opt_host, 1, (uint8_t *)&info1, &parm_error);
+
+       if (status != 0) {
+               d_fprintf(stderr, "Failed to add user '%s' with: %s.\n",
+                       argv[0], libnetapi_get_error_string(NULL, status));
+               return -1;
+       } else {
+               d_printf("Added user '%s'.\n", argv[0]);
+       }
+
+       return 0;
 }
 
 /**