netapi: implement NetRenameMachineInDomain_r.
authorGünther Deschner <gd@samba.org>
Tue, 2 Sep 2008 11:17:57 +0000 (13:17 +0200)
committerGünther Deschner <gd@samba.org>
Fri, 5 Sep 2008 11:13:44 +0000 (13:13 +0200)
Guenther
(This used to be commit 39a42380ca3fac92eb27bded90ab06f7760937b9)

source3/lib/netapi/joindomain.c

index 6bf1cad312f6a132516a6419b750f3b1239886d6..d15e2e733c25f901d55205ae1ea18e5c56b62a3f 100644 (file)
@@ -454,7 +454,41 @@ WERROR NetGetJoinableOUs_r(struct libnetapi_ctx *ctx,
 WERROR NetRenameMachineInDomain_r(struct libnetapi_ctx *ctx,
                                  struct NetRenameMachineInDomain *r)
 {
-       return WERR_NOT_SUPPORTED;
+       struct cli_state *cli = NULL;
+       struct rpc_pipe_client *pipe_cli = NULL;
+       struct wkssvc_PasswordBuffer *encrypted_password = NULL;
+       NTSTATUS status;
+       WERROR werr;
+
+       werr = libnetapi_open_pipe(ctx, r->in.server_name,
+                                  &ndr_table_wkssvc.syntax_id,
+                                  &cli,
+                                  &pipe_cli);
+       if (!W_ERROR_IS_OK(werr)) {
+               goto done;
+       }
+
+       if (r->in.password) {
+               encode_wkssvc_join_password_buffer(ctx,
+                                                  r->in.password,
+                                                  &cli->user_session_key,
+                                                  &encrypted_password);
+       }
+
+       status = rpccli_wkssvc_NetrRenameMachineInDomain2(pipe_cli, ctx,
+                                                         r->in.server_name,
+                                                         r->in.new_machine_name,
+                                                         r->in.account,
+                                                         encrypted_password,
+                                                         r->in.rename_options,
+                                                         &werr);
+       if (!NT_STATUS_IS_OK(status)) {
+               werr = ntstatus_to_werror(status);
+               goto done;
+       }
+
+ done:
+       return werr;
 }
 
 /****************************************************************