summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2007-11-30 20:20:54 +0100
committerVolker Lendecke <vl@sernet.de>2007-11-30 22:25:01 +0100
commitc88263ab9e8b3111742e5ce53b5aa29bba65e5ee (patch)
tree6b425100ef90fa3c1f008617c0208e7c9f4255ec /source3
parent4b60045066b80f4328fe7ea0e0a7e5d29b0a496b (diff)
downloadsamba-c88263ab9e8b3111742e5ce53b5aa29bba65e5ee.tar.gz
samba-c88263ab9e8b3111742e5ce53b5aa29bba65e5ee.tar.bz2
samba-c88263ab9e8b3111742e5ce53b5aa29bba65e5ee.zip
Add "net dom unjoin" code.
Guenther (This used to be commit 58d49023b9bc7d27e770f18a25cc6cebdc95b300)
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/net_dom.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/source3/utils/net_dom.c b/source3/utils/net_dom.c
index a4f5d1dd03..79130a8810 100644
--- a/source3/utils/net_dom.c
+++ b/source3/utils/net_dom.c
@@ -25,6 +25,8 @@ static int net_dom_usage(int argc, const char **argv)
{
d_printf("usage: net dom join "
"<domain=DOMAIN> <ou=OU> <account=ACCOUNT> <password=PASSWORD> <reboot>\n");
+ d_printf("usage: net dom unjoin "
+ "<account=ACCOUNT> <password=PASSWORD> <reboot>\n");
return -1;
}
@@ -33,10 +35,59 @@ int net_help_dom(int argc, const char **argv)
{
d_printf("net dom join"\
"\n Join a remote machine\n");
+ d_printf("net dom unjoin"\
+ "\n Unjoin a remote machine\n");
return -1;
}
+static int net_dom_unjoin(int argc, const char **argv)
+{
+ const char *server_name = NULL;
+ const char *account = NULL;
+ const char *password = NULL;
+ uint32_t unjoin_flags = WKSSVC_JOIN_FLAGS_ACCOUNT_DELETE |
+ WKSSVC_JOIN_FLAGS_JOIN_TYPE;
+ bool reboot = false;
+ WERROR werr;
+ int i;
+
+ if (argc < 1) {
+ return net_dom_usage(argc, argv);
+ }
+
+ server_name = opt_host;
+
+ for (i=0; i<argc; i++) {
+ if (strnequal(argv[i], "account", strlen("account"))) {
+ account = get_string_param(argv[i]);
+ if (!account) {
+ return -1;
+ }
+ }
+ if (strnequal(argv[i], "password", strlen("password"))) {
+ password = get_string_param(argv[i]);
+ if (!password) {
+ return -1;
+ }
+ }
+ if (strequal(argv[i], "reboot")) {
+ reboot = true;
+ }
+ }
+
+ werr = NetUnjoinDomain(server_name, account, password, unjoin_flags);
+ if (!W_ERROR_IS_OK(werr)) {
+ printf("Failed to unjoin domain: %s\n",
+ get_friendly_nt_error_msg(werror_to_ntstatus(werr)));
+ return -1;
+ }
+
+ /* reboot then */
+
+ return 0;
+}
+
static int net_dom_join(int argc, const char **argv)
{
const char *server_name = NULL;
@@ -109,6 +160,7 @@ int net_dom(int argc, const char **argv)
{
struct functable func[] = {
{"JOIN", net_dom_join},
+ {"UNJOIN", net_dom_unjoin},
{NULL, NULL}
};