summaryrefslogtreecommitdiff
path: root/source3/lib/netapi
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2007-11-30 19:57:08 +0100
committerVolker Lendecke <vl@sernet.de>2007-11-30 22:25:01 +0100
commit9fdb8b82c966cf59a26008f26d070ffb7683b0c4 (patch)
tree292da787157411a4ee75a617218efd15aeff9620 /source3/lib/netapi
parentac512a5bb2113aed1d41ef5479a75b8e05918876 (diff)
downloadsamba-9fdb8b82c966cf59a26008f26d070ffb7683b0c4.tar.gz
samba-9fdb8b82c966cf59a26008f26d070ffb7683b0c4.tar.bz2
samba-9fdb8b82c966cf59a26008f26d070ffb7683b0c4.zip
Add NetUnjoinDomain().
Guenther (This used to be commit fd9d73ad44b0f0b3656a50a663b60aa26e7f7376)
Diffstat (limited to 'source3/lib/netapi')
-rw-r--r--source3/lib/netapi/joindomain.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c
index 29766e5994..66f0137cad 100644
--- a/source3/lib/netapi/joindomain.c
+++ b/source3/lib/netapi/joindomain.c
@@ -100,3 +100,77 @@ WERROR NetJoinDomain(const char *server_name,
return werr;
}
+
+WERROR NetUnjoinDomain(const char *server_name,
+ const char *account,
+ const char *password,
+ uint32_t unjoin_flags)
+{
+ TALLOC_CTX *mem_ctx = NULL;
+ struct cli_state *cli = NULL;
+ struct rpc_pipe_client *pipe_cli = NULL;
+ struct wkssvc_PasswordBuffer encrypted_password;
+ NTSTATUS status;
+ WERROR werr;
+ unsigned int old_timeout;
+
+ ZERO_STRUCT(encrypted_password);
+
+ mem_ctx = talloc_init("NetUnjoinDomain");
+ if (!mem_ctx) {
+ werr = WERR_NOMEM;
+ goto done;
+ }
+
+ if (!server_name || is_myname_or_ipaddr(server_name)) {
+ werr = WERR_NOT_SUPPORTED;
+ goto done;
+ }
+
+ status = net_make_ipc_connection_ex(NULL,
+ server_name,
+ NULL, 0, &cli);
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
+ old_timeout = cli_set_timeout(cli, 60000);
+
+ pipe_cli = cli_rpc_pipe_open_noauth(cli, PI_WKSSVC,
+ &status);
+ if (!pipe_cli) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ };
+
+ if (password) {
+ encode_wkssvc_join_password_buffer(mem_ctx,
+ password,
+ &cli->user_session_key,
+ &encrypted_password);
+ }
+
+ old_timeout = cli_set_timeout(cli, 60000);
+
+ status = rpccli_wkssvc_NetrUnjoinDomain2(pipe_cli, mem_ctx,
+ server_name,
+ account,
+ &encrypted_password,
+ unjoin_flags);
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
+ werr = WERR_OK;
+
+ done:
+ if (cli) {
+ cli_set_timeout(cli, old_timeout);
+ cli_shutdown(cli);
+ }
+ TALLOC_FREE(mem_ctx);
+
+ return werr;
+}