summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-04-16 02:41:52 +0200
committerGünther Deschner <gd@samba.org>2008-04-16 02:41:52 +0200
commit004c2beef4e4b89cb361cbd4cf71ef7635121fd5 (patch)
treef0393c08b1fd9d3401ef43418ec76ce80a687bd2
parentcd87be5ba22e711e16d7f1feb5be753807efdc05 (diff)
downloadsamba-004c2beef4e4b89cb361cbd4cf71ef7635121fd5.tar.gz
samba-004c2beef4e4b89cb361cbd4cf71ef7635121fd5.tar.bz2
samba-004c2beef4e4b89cb361cbd4cf71ef7635121fd5.zip
net: Use NetUserAdd for "net rpc user add".
Guenther (This used to be commit 4868b4ea1a18d4218330c49bf57818c4b5117d1d)
-rw-r--r--source3/utils/net_rpc.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 3cd72fa3d8..d0e0487372 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -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;
}
/**