1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-13 16:23:50 +03:00

Fix up 'net ads join' to delete and rejoin if the account already exists.

This fixes up a problem where a machine would join (or downgrade by trust
password change) to NT4 membership and not be able to regain full ADS
membership until a 'net ads leave'.

Andrew Bartlett
This commit is contained in:
Andrew Bartlett
-
parent da4db0373b
commit ab8ff85f03
2 changed files with 8 additions and 3 deletions

View File

@@ -321,8 +321,13 @@ ADS_STATUS ads_join_realm(ADS_STRUCT *ads, const char *hostname, const char *org
status = ads_find_machine_acct(ads, (void **)&res, host); status = ads_find_machine_acct(ads, (void **)&res, host);
if (ADS_ERR_OK(status) && ads_count_replies(ads, res) == 1) { if (ADS_ERR_OK(status) && ads_count_replies(ads, res) == 1) {
DEBUG(0, ("Host account for %s already exists\n", host)); DEBUG(0, ("Host account for %s already exists - deleting for readd\n", host));
return ADS_SUCCESS; status = ads_leave_realm(ads, host);
if (!ADS_ERR_OK(status)) {
DEBUG(0, ("Failed to delete host '%s' from the '%s' realm.\n",
host, ads->realm));
return status;
}
} }
status = ads_add_machine_acct(ads, host, org_unit); status = ads_add_machine_acct(ads, host, org_unit);

View File

@@ -1257,7 +1257,7 @@ again:
if (!cli_negprot(cli)) if (!cli_negprot(cli))
{ {
DEBUG(1,("failed negprot\n")); DEBUG(1,("failed negprot\n"));
nt_status = cli_nt_error(cli); nt_status = NT_STATUS_UNSUCCESSFUL;
cli_shutdown(cli); cli_shutdown(cli);
return nt_status; return nt_status;
} }