1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-04 08:22:08 +03:00

r18467: Some sites allow an account to be deleted, but not

disabled. Cope with both - print appropriate messages.
Jeremy.
This commit is contained in:
Jeremy Allison
2006-09-13 13:28:42 +00:00
committed by Gerald (Jerry) Carter
parent 1398425067
commit 2c003a4463

View File

@ -755,10 +755,12 @@ static int net_ads_status(int argc, const char **argv)
That only worked using the machine creds because added the machine That only worked using the machine creds because added the machine
with full control to the computer object's ACL. with full control to the computer object's ACL.
*******************************************************************/ *******************************************************************/
static int net_ads_leave(int argc, const char **argv) static int net_ads_leave(int argc, const char **argv)
{ {
ADS_STRUCT *ads = NULL; ADS_STRUCT *ads = NULL;
ADS_STATUS adsret; ADS_STATUS adsret;
NTSTATUS status;
int ret = -1; int ret = -1;
struct cli_state *cli = NULL; struct cli_state *cli = NULL;
TALLOC_CTX *ctx; TALLOC_CTX *ctx;
@ -795,28 +797,29 @@ static int net_ads_leave(int argc, const char **argv)
goto done; goto done;
} }
if ( !NT_STATUS_IS_OK(netdom_leave_domain( ctx, cli, dom_sid )) ) { status = netdom_leave_domain(ctx, cli, dom_sid);
d_fprintf(stderr, "Failed to disable machine account for '%s' in realm '%s'\n",
global_myname(), ads->config.realm);
goto done;
}
ret = 0; /* Ty and delete it via LDAP - the old way we used to. */
/* Now we've disabled the account, try and delete it
via LDAP - the old way we used to. Don't log a failure
if this failed. */
adsret = ads_leave_realm(ads, global_myname()); adsret = ads_leave_realm(ads, global_myname());
if (ADS_ERR_OK(adsret)) { if (ADS_ERR_OK(adsret)) {
d_printf("Deleted account for '%s' in realm '%s'\n", d_printf("Deleted account for '%s' in realm '%s'\n",
global_myname(), ads->config.realm); global_myname(), ads->config.realm);
ret = 0;
} else { } else {
/* We couldn't delete it - see if the disable succeeded. */
if (NT_STATUS_IS_OK(status)) {
d_printf("Disabled account for '%s' in realm '%s'\n", d_printf("Disabled account for '%s' in realm '%s'\n",
global_myname(), ads->config.realm); global_myname(), ads->config.realm);
ret = 0;
} else {
d_fprintf(stderr, "Failed to disable machine account for '%s' in realm '%s'\n",
global_myname(), ads->config.realm);
}
} }
done: done:
if ( cli ) if ( cli )
cli_shutdown(cli); cli_shutdown(cli);