}
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
- system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
+ system_session(dce_call->conn->dce_ctx->lp_ctx));
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
}
nt_status = schannel_store_session_key_ldb(schannel_ldb, mem_ctx, creds);
- talloc_free(schannel_ldb);
+ talloc_unlink(mem_ctx, schannel_ldb);
return nt_status;
}
schannel_in_use,
received_authenticator,
return_authenticator, creds_out);
- talloc_free(ldb);
+ talloc_unlink(mem_ctx, ldb);
return nt_status;
}
&creds);
NT_STATUS_NOT_OK_RETURN(nt_status);
- sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
+ sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(dce_call->conn->dce_ctx->lp_ctx));
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
&creds);
NT_STATUS_NOT_OK_RETURN(nt_status);
- sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
+ sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(dce_call->conn->dce_ctx->lp_ctx));
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
sam6 = talloc_zero(mem_ctx, struct netr_SamInfo6);
NT_STATUS_HAVE_NO_MEMORY(sam6);
sam6->base = *sam;
- sam6->forest.string = lp_realm(dce_call->conn->dce_ctx->lp_ctx);
+ sam6->forest.string = lp_dnsdomain(dce_call->conn->dce_ctx->lp_ctx);
sam6->principle.string = talloc_asprintf(mem_ctx, "%s@%s",
sam->account_name.string, sam6->forest.string);
NT_STATUS_HAVE_NO_MEMORY(sam6->principle.string);
if (is_local) {
info->domainname.string = lp_sam_name(lp_ctx);
- info->dns_domainname.string = lp_realm(lp_ctx);
+ info->dns_domainname.string = lp_dnsdomain(lp_ctx);
info->domain_guid = samdb_result_guid(res, "objectGUID");
info->domain_sid = samdb_result_dom_sid(mem_ctx, res, "objectSid");
} else {
struct netlogon_creds_CredentialState *creds;
const char * const attrs[] = { "objectSid", "objectGUID", "flatName",
"securityIdentifier", "trustPartner", NULL };
+ const char * const attrs2[] = { "dNSHostName",
+ "msDS-SupportedEncryptionTypes", NULL };
const char *temp_str;
const char *old_dns_hostname;
struct ldb_context *sam_ctx;
- struct ldb_message **res1, **res2, *new_msg;
+ struct ldb_message **res1, **res2, **res3, *new_msg;
struct ldb_dn *workstation_dn;
struct netr_DomainInformation *domain_info;
struct netr_LsaPolicyInformation *lsa_policy_info;
struct netr_OsVersionInfoEx *os_version;
uint32_t default_supported_enc_types = 0xFFFFFFFF;
- int ret1, ret2, i;
+ int ret1, ret2, ret3, i;
NTSTATUS status;
status = dcesrv_netr_creds_server_step_check(dce_call,
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx,
dce_call->conn->dce_ctx->lp_ctx,
- system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
+ system_session(dce_call->conn->dce_ctx->lp_ctx));
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
dom_sid_string(mem_ctx, creds->sid));
NT_STATUS_HAVE_NO_MEMORY(workstation_dn);
+ /* Lookup for attributes in workstation object */
+ ret1 = gendb_search_dn(sam_ctx, mem_ctx, workstation_dn,
+ &res1, attrs2);
+ if (ret1 != 1) {
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
+
/* Gets the old DNS hostname */
- old_dns_hostname = samdb_search_string(sam_ctx, mem_ctx,
- workstation_dn,
- "dNSHostName",
- NULL);
+ old_dns_hostname = samdb_result_string(res1[0], "dNSHostName",
+ NULL);
/* Gets host informations and put them in our directory */
new_msg = ldb_msg_new(mem_ctx);
"operatingSystem",
r->in.query->workstation_info->os_name.string);
+ if (r->in.query->workstation_info->dns_hostname) {
+ /* TODO: should this always be done? */
+ samdb_msg_add_string(sam_ctx, mem_ctx, new_msg,
+ "dNSHostname",
+ r->in.query->workstation_info->dns_hostname);
+ }
+
/*
* Sets informations from "os_version". On a empty structure
* the values are cleared.
if ((r->in.query->workstation_info->workstation_flags
& NETR_WS_FLAG_HANDLES_SPN_UPDATE) == 0) {
- samdb_msg_add_string(sam_ctx, mem_ctx, new_msg,
- "dNSHostname",
- r->in.query->workstation_info->dns_hostname);
samdb_msg_add_string(sam_ctx, mem_ctx, new_msg,
"servicePrincipalName",
talloc_asprintf(mem_ctx, "HOST/%s",
primary domain is also a "trusted" domain, so we need to
put the primary domain into the lists of returned trusts as
well. */
- ret1 = gendb_search_dn(sam_ctx, mem_ctx, samdb_base_dn(sam_ctx),
- &res1, attrs);
- if (ret1 != 1) {
+ ret2 = gendb_search_dn(sam_ctx, mem_ctx, samdb_base_dn(sam_ctx),
+ &res2, attrs);
+ if (ret2 != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
- ret2 = gendb_search(sam_ctx, mem_ctx, NULL, &res2, attrs,
+ ret3 = gendb_search(sam_ctx, mem_ctx, NULL, &res3, attrs,
"(objectClass=trustedDomain)");
- if (ret2 == -1) {
+ if (ret3 == -1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
status = fill_one_domain_info(mem_ctx,
dce_call->conn->dce_ctx->lp_ctx,
- sam_ctx, res1[0], &domain_info->primary_domain,
+ sam_ctx, res2[0], &domain_info->primary_domain,
true, false);
NT_STATUS_NOT_OK_RETURN(status);
- domain_info->trusted_domain_count = ret2 + 1;
+ domain_info->trusted_domain_count = ret3 + 1;
domain_info->trusted_domains = talloc_array(mem_ctx,
struct netr_OneDomainInfo,
domain_info->trusted_domain_count);
NT_STATUS_HAVE_NO_MEMORY(domain_info->trusted_domains);
- for (i=0;i<ret2;i++) {
+ for (i=0;i<ret3;i++) {
status = fill_one_domain_info(mem_ctx,
dce_call->conn->dce_ctx->lp_ctx,
- sam_ctx, res2[i],
+ sam_ctx, res3[i],
&domain_info->trusted_domains[i],
false, true);
NT_STATUS_NOT_OK_RETURN(status);
}
status = fill_one_domain_info(mem_ctx,
- dce_call->conn->dce_ctx->lp_ctx, sam_ctx, res1[0],
+ dce_call->conn->dce_ctx->lp_ctx, sam_ctx, res2[0],
&domain_info->trusted_domains[i], true, true);
NT_STATUS_NOT_OK_RETURN(status);
/* Sets the supported encryption types */
- domain_info->supported_enc_types = samdb_search_uint(
- sam_ctx, mem_ctx,
- default_supported_enc_types, workstation_dn,
- "msDS-SupportedEncryptionTypes", NULL);
+ domain_info->supported_enc_types = samdb_result_uint(res1[0],
+ "msDS-SupportedEncryptionTypes",
+ default_supported_enc_types);
/* Other host domain informations */
return WERR_DS_UNAVAILABLE;
}
- /* Win7-beta will send the domain name in the form the user typed, so we have to cope
- with both the short and long form here */
- if (r->in.domain_name != NULL && !lp_is_my_domain_or_realm(dce_call->conn->dce_ctx->lp_ctx,
- r->in.domain_name)) {
+ /* Windows 7 sends the domain name in the form the user typed, so we
+ * have to cope with both the short and long form here */
+ if (r->in.domain_name != NULL &&
+ !lp_is_my_domain_or_realm(dce_call->conn->dce_ctx->lp_ctx,
+ r->in.domain_name)) {
return WERR_NO_SUCH_DOMAIN;
}
*/
info->dc_unc = talloc_asprintf(mem_ctx, "\\\\%s.%s",
lp_netbios_name(dce_call->conn->dce_ctx->lp_ctx),
- lp_realm(dce_call->conn->dce_ctx->lp_ctx));
+ lp_dnsdomain(dce_call->conn->dce_ctx->lp_ctx));
W_ERROR_HAVE_NO_MEMORY(info->dc_unc);
info->dc_address = talloc_strdup(mem_ctx, "\\\\0.0.0.0");
W_ERROR_HAVE_NO_MEMORY(info->dc_address);
info->dc_address_type = DS_ADDRESS_TYPE_INET;
info->domain_guid = samdb_result_guid(res[0], "objectGUID");
- info->domain_name = lp_realm(dce_call->conn->dce_ctx->lp_ctx);
- info->forest_name = lp_realm(dce_call->conn->dce_ctx->lp_ctx);
- info->dc_flags = DS_DNS_FOREST |
+ info->domain_name = lp_dnsdomain(dce_call->conn->dce_ctx->lp_ctx);
+ info->forest_name = lp_dnsdomain(dce_call->conn->dce_ctx->lp_ctx);
+ info->dc_flags = DS_DNS_FOREST_ROOT |
DS_DNS_DOMAIN |
DS_DNS_CONTROLLER |
DS_SERVER_WRITABLE |
DS_SERVER_LDAP |
DS_SERVER_GC |
DS_SERVER_PDC;
- info->dc_site_name = talloc_strdup(mem_ctx, "Default-First-Site-Name");
+ info->dc_site_name = samdb_server_site_name(sam_ctx, mem_ctx);
W_ERROR_HAVE_NO_MEMORY(info->dc_site_name);
+ /* FIXME: Hardcoded site name */
info->client_site_name = talloc_strdup(mem_ctx, "Default-First-Site-Name");
W_ERROR_HAVE_NO_MEMORY(info->client_site_name);
W_ERROR_HAVE_NO_MEMORY(ctr->subnetname);
for (i=0; i<ctr->count; i++) {
+ /* FIXME: Hardcoded site name */
ctr->sitename[i].string = "Default-First-Site-Name";
ctr->subnetname[i].string = NULL;
}
/* TODO: add filtering by trust_flags, and correct trust_type
and attributes */
trusts->array[0].netbios_name = lp_sam_name(dce_call->conn->dce_ctx->lp_ctx);
- trusts->array[0].dns_name = lp_realm(dce_call->conn->dce_ctx->lp_ctx);
+ trusts->array[0].dns_name = lp_dnsdomain(dce_call->conn->dce_ctx->lp_ctx);
trusts->array[0].trust_flags =
NETR_TRUST_FLAG_TREEROOT |
NETR_TRUST_FLAG_IN_FOREST |