TALLOC_CTX *mem_ctx,
ADS_STRUCT **adsp)
{
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
char *ldap_server = NULL;
char *realm = NULL;
char *password = NULL;
* Make sure we never try to use LDAP against
* a trusted domain as AD DC.
*/
+ TALLOC_FREE(tmp_ctx);
return ADS_ERROR_NT(NT_STATUS_REQUEST_NOT_ACCEPTED);
}
ads_cached_connection_reuse(adsp);
if (*adsp != NULL) {
+ TALLOC_FREE(tmp_ctx);
return ADS_SUCCESS;
}
* Check if we can get server nam and realm from SAF cache
* and the domain list.
*/
- ldap_server = saf_fetch(talloc_tos(), dom_name);
+ ldap_server = saf_fetch(tmp_ctx, dom_name);
+
DBG_DEBUG("ldap_server from saf cache: '%s'\n",
ldap_server ? ldap_server : "");
if (IS_DC) {
SMB_ASSERT(wb_dom->alt_name != NULL);
- realm = SMB_STRDUP(wb_dom->alt_name);
+ realm = talloc_strdup(tmp_ctx, wb_dom->alt_name);
} else {
struct winbindd_domain *our_domain = wb_dom;
}
if (our_domain->alt_name != NULL) {
- realm = SMB_STRDUP(our_domain->alt_name);
+ realm = talloc_strdup(tmp_ctx, our_domain->alt_name);
} else {
- realm = SMB_STRDUP(lp_realm());
+ realm = talloc_strdup(tmp_ctx, lp_realm());
}
}
+ if (realm == NULL) {
+ status = ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
+ goto out;
+ }
+
status = ads_cached_connection_connect(
adsp, /* Returns ads struct. */
wb_dom->alt_name, /* realm to connect to. */
0); /* renewable ticket time. */
out:
- SAFE_FREE(realm);
+ TALLOC_FREE(tmp_ctx);
SAFE_FREE(password);
- TALLOC_FREE(ldap_server);
return status;
}