From 6154b031f4521fad4b5c460643da59dd918b240a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 12 May 2009 22:46:36 +0200 Subject: s3-netdomjoin-gui: prepare to call out for NetRenameMachineInDomain() to rename computers in domains. Guenther --- .../examples/netdomjoin-gui/netdomjoin-gui.c | 49 +++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'source3/lib/netapi/examples') diff --git a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c index 7652b4584c..66e95720cd 100644 --- a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c +++ b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c @@ -81,6 +81,12 @@ typedef struct join_state { uid_t uid; } join_state; +static void callback_creds_prompt(GtkWidget *widget, + gpointer data, + const char *label_string, + gpointer cont_fn); + + static void debug(const char *format, ...) { va_list args; @@ -459,9 +465,50 @@ static void callback_do_hostname_change(GtkWidget *widget, struct join_state *state = (struct join_state *)data; switch (state->name_type_initial) { - case NetSetupDomainName: + case NetSetupDomainName: { +#if 0 + NET_API_STATUS status; + const char *newname; + char *p = NULL; + + newname = strdup(gtk_label_get_text(GTK_LABEL(state->label_full_computer_name))); + if (!newname) { + return; + } + + p = strchr(newname, '.'); + if (p) { + *p = NULL; + } + + if (!state->account || !state->password) { + debug("callback_do_hostname_change: no creds yet\n"); + callback_creds_prompt(NULL, state, + "Enter the name and password of an account with permission to change a computer name in a the domain.", + callback_do_storeauth_and_continue); + } + + if (!state->account || !state->password) { + debug("callback_do_hostname_change: still no creds???\n"); + return; + } + + status = NetRenameMachineInDomain(state->target_hostname, + newname, + state->account, + state->password, + NETSETUP_ACCT_CREATE); + SAFE_FREE(newname); + /* we renamed the machine in the domain */ + if (status == 0) { + return; + } + str = libnetapi_get_error_string(state->ctx, status); +#else str = "To be implemented: call NetRenameMachineInDomain\n"; +#endif break; + } case NetSetupWorkgroupName: str = "To be implemented: call SetComputerNameEx\n"; break; -- cgit