summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-04-16 02:39:41 +0200
committerGünther Deschner <gd@samba.org>2008-04-16 02:39:41 +0200
commitcd87be5ba22e711e16d7f1feb5be753807efdc05 (patch)
tree390f5f76c0f7c342dd665f5b0d4aec29e26ee267
parent3455702721c0888a475afe3e0fe2e8469aa8cdd3 (diff)
downloadsamba-cd87be5ba22e711e16d7f1feb5be753807efdc05.tar.gz
samba-cd87be5ba22e711e16d7f1feb5be753807efdc05.tar.bz2
samba-cd87be5ba22e711e16d7f1feb5be753807efdc05.zip
net: use NetUserDel for "net rpc user delete".
Guenther (This used to be commit 0105770c1598e6fcbcaa29e17f3b7fd33114a333)
-rw-r--r--source3/utils/net_rpc.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 5663680eb7..3cd72fa3d8 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -987,8 +987,26 @@ static int rpc_user_rename(int argc, const char **argv)
static int rpc_user_delete(int argc, const char **argv)
{
- return run_rpc_command(NULL, PI_SAMR, 0, rpc_user_del_internals,
- argc, argv);
+ NET_API_STATUS status;
+
+ if (argc < 1) {
+ d_printf("User must be specified\n");
+ rpc_user_usage(argc, argv);
+ return 0;
+ }
+
+ status = NetUserDel(opt_host, argv[0]);
+
+ if (status != 0) {
+ d_fprintf(stderr, "Failed to delete user '%s' with: %s.\n",
+ argv[0],
+ libnetapi_get_error_string(NULL, status));
+ return -1;
+ } else {
+ d_printf("Deleted user '%s'.\n", argv[0]);
+ }
+
+ return 0;
}
/**
@@ -1360,6 +1378,9 @@ static NTSTATUS rpc_user_list_internals(const DOM_SID *domain_sid,
int net_rpc_user(int argc, const char **argv)
{
+ struct libnetapi_ctx *ctx = NULL;
+ NET_API_STATUS status;
+
struct functable func[] = {
{"add", rpc_user_add},
{"info", rpc_user_info},
@@ -1368,7 +1389,14 @@ int net_rpc_user(int argc, const char **argv)
{"rename", rpc_user_rename},
{NULL, NULL}
};
-
+
+ status = libnetapi_init(&ctx);
+ if (status != 0) {
+ return -1;
+ }
+ libnetapi_set_username(ctx, opt_user_name);
+ libnetapi_set_password(ctx, opt_password);
+
if (argc == 0) {
return run_rpc_command(NULL,PI_SAMR, 0,
rpc_user_list_internals,