1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

try to use our workstation account password for ADS leave

This commit is contained in:
Andrew Tridgell 0001-01-01 00:00:00 +00:00
parent 3db97530b6
commit 2a42e91397

View File

@ -197,16 +197,23 @@ static int net_ads_leave(int argc, const char **argv)
ADS_STRUCT *ads = NULL;
ADS_STATUS rc;
extern pstring global_myname;
if (!(ads = ads_startup())) {
return -1;
}
extern char *opt_user_name;
extern char *opt_password;
if (!secrets_init()) {
DEBUG(1,("Failed to initialise secrets database\n"));
return -1;
}
if (!opt_password) {
asprintf(&opt_user_name, "%s$", global_myname);
opt_password = secrets_fetch_machine_password();
}
if (!(ads = ads_startup())) {
return -1;
}
rc = ads_leave_realm(ads, global_myname);
if (!ADS_ERR_OK(rc)) {
d_printf("Failed to delete host '%s' from the '%s' realm.\n",
@ -252,7 +259,7 @@ static int net_ads_join(int argc, const char **argv)
ads_msgfree(ads, res);
if (rc.error_type == ADS_ERROR_LDAP && rc.rc == LDAP_NO_SUCH_OBJECT) {
d_printf("ads_join_realm: organisational unit %s does not exist (dn:%s)\n",
d_printf("ads_join_realm: organizational unit %s does not exist (dn:%s)\n",
org_unit, dn);
return -1;
}