diff options
-rw-r--r-- | source4/auth/auth_sam.c | 2 | ||||
-rw-r--r-- | source4/auth/sam.c | 2 | ||||
-rw-r--r-- | source4/cldap_server/netlogon.c | 4 | ||||
-rw-r--r-- | source4/dsdb/samdb/cracknames.c | 4 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/password_hash.c | 2 | ||||
-rw-r--r-- | source4/dsdb/samdb/samdb.c | 39 | ||||
-rw-r--r-- | source4/kdc/hdb-ldb.c | 4 | ||||
-rw-r--r-- | source4/nbt_server/dgram/netlogon.c | 4 | ||||
-rw-r--r-- | source4/rpc_server/dssetup/dcesrv_dssetup.c | 2 | ||||
-rw-r--r-- | source4/rpc_server/lsa/dcesrv_lsa.c | 6 | ||||
-rw-r--r-- | source4/rpc_server/netlogon/dcerpc_netlogon.c | 4 | ||||
-rw-r--r-- | source4/rpc_server/samr/dcesrv_samr.c | 12 |
12 files changed, 38 insertions, 47 deletions
diff --git a/source4/auth/auth_sam.c b/source4/auth/auth_sam.c index ee9a308ed8..3d28b88446 100644 --- a/source4/auth/auth_sam.c +++ b/source4/auth/auth_sam.c @@ -45,7 +45,7 @@ static NTSTATUS authsam_search_account(TALLOC_CTX *mem_ctx, struct ldb_context * struct ldb_message **msgs_tmp; struct ldb_message **msgs; struct ldb_message **msgs_domain_ref; - const struct ldb_dn *partitions_basedn = ldb_dn_string_compose(mem_ctx, samdb_base_dn(mem_ctx), "CN=Partitions,CN=Configuration"); + const struct ldb_dn *partitions_basedn = samdb_partitions_dn(sam_ctx, mem_ctx); int ret; int ret_domain; diff --git a/source4/auth/sam.c b/source4/auth/sam.c index f616138a3e..0284cb9a19 100644 --- a/source4/auth/sam.c +++ b/source4/auth/sam.c @@ -321,7 +321,7 @@ _PUBLIC_ NTSTATUS sam_get_results_principal(struct ldb_context *sam_ctx, NTSTATUS nt_status; TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); int ret; - const struct ldb_dn *partitions_basedn = ldb_dn_string_compose(mem_ctx, samdb_base_dn(mem_ctx), "CN=Partitions,CN=Configuration"); + const struct ldb_dn *partitions_basedn = samdb_partitions_dn(sam_ctx, mem_ctx); if (!tmp_ctx) { return NT_STATUS_NO_MEMORY; diff --git a/source4/cldap_server/netlogon.c b/source4/cldap_server/netlogon.c index 16d2362d06..74e7b3c7e5 100644 --- a/source4/cldap_server/netlogon.c +++ b/source4/cldap_server/netlogon.c @@ -62,7 +62,7 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd, const char *site_name; const char *site_name2; const char *pdc_ip; - const struct ldb_dn *partitions_basedn = ldb_dn_string_compose(mem_ctx, samdb_base_dn(mem_ctx), "CN=Partitions,CN=Configuration"); + const struct ldb_dn *partitions_basedn; if (cldapd->samctx == NULL) { cldapd->samctx = samdb_connect(cldapd, anonymous_session(cldapd)); @@ -72,6 +72,8 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd, } } + partitions_basedn = samdb_partitions_dn(cldapd->samctx, mem_ctx); + /* the domain has an optional trailing . */ if (domain && domain[strlen(domain)-1] == '.') { domain = talloc_strndup(mem_ctx, domain, strlen(domain)-1); diff --git a/source4/dsdb/samdb/cracknames.c b/source4/dsdb/samdb/cracknames.c index e8fd1fa71b..76bc80689b 100644 --- a/source4/dsdb/samdb/cracknames.c +++ b/source4/dsdb/samdb/cracknames.c @@ -577,7 +577,7 @@ static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ const char * const *result_attrs; struct ldb_message **result_res = NULL; const struct ldb_dn *result_basedn; - const struct ldb_dn *partitions_basedn = ldb_dn_string_compose(mem_ctx, samdb_base_dn(mem_ctx), "CN=Partitions,CN=Configuration"); + const struct ldb_dn *partitions_basedn = samdb_partitions_dn(sam_ctx, mem_ctx); const char * const _domain_attrs_1779[] = { "ncName", "dnsRoot", NULL}; const char * const _result_attrs_null[] = { NULL }; @@ -627,7 +627,7 @@ static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ "%s", domain_filter); } else { ldb_ret = gendb_search(sam_ctx, mem_ctx, partitions_basedn, &domain_res, domain_attrs, - "(ncName=%s)", ldb_dn_linearize(mem_ctx, samdb_base_dn(mem_ctx))); + "(ncName=%s)", ldb_dn_linearize(mem_ctx, samdb_base_dn(sam_ctx))); } switch (ldb_ret) { diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c index 273cc60c30..e8b9307cf5 100644 --- a/source4/dsdb/samdb/ldb_modules/password_hash.c +++ b/source4/dsdb/samdb/ldb_modules/password_hash.c @@ -489,7 +489,7 @@ static int build_domain_data_request(struct ph_context *ac) return LDB_ERR_OPERATIONS_ERROR; } ac->dom_req->operation = LDB_SEARCH; - ac->dom_req->op.search.base = samdb_base_dn(ac); + ac->dom_req->op.search.base = ldb_auto_basedn(ac->module->ldb); ac->dom_req->op.search.scope = LDB_SCOPE_SUBTREE; filter = talloc_asprintf(ac->dom_req, "(&(objectSid=%s)(|(objectClass=domain)(objectClass=builtinDomain)))", diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c index 4027203b24..dd671e6a2b 100644 --- a/source4/dsdb/samdb/samdb.c +++ b/source4/dsdb/samdb/samdb.c @@ -1024,38 +1024,17 @@ struct security_descriptor *samdb_default_security_descriptor(TALLOC_CTX *mem_ct return sd; } -const struct ldb_dn *samdb_base_dn(TALLOC_CTX *mem_ctx) +const struct ldb_dn *samdb_base_dn(struct ldb_context *sam_ctx) { - TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); - int server_role = lp_server_role(); - const char **split_realm; - struct ldb_dn *dn; - - if (!tmp_ctx) { - return NULL; - } + return ldb_auto_basedn(sam_ctx); +} - if ((server_role == ROLE_DOMAIN_PDC) - || (server_role == ROLE_DOMAIN_BDC)) { - int i; - split_realm = str_list_make(tmp_ctx, lp_realm(), "."); - if (!split_realm) { - talloc_free(tmp_ctx); - return NULL; - } - dn = NULL; - i = str_list_length(split_realm); - i--; - for (; i >= 0; i--) { - dn = ldb_dn_build_child(tmp_ctx, "dc", split_realm[i], dn); - if (!dn) { - talloc_free(tmp_ctx); - return NULL; - } - } - return dn; - } - return ldb_dn_string_compose(mem_ctx, NULL, "cn=%s", lp_netbios_name()); + +const struct ldb_dn *samdb_partitions_dn(struct ldb_context *sam_ctx, + TALLOC_CTX *mem_ctx) +{ + return ldb_dn_string_compose(mem_ctx, samdb_base_dn(sam_ctx), + "CN=Partitions,CN=Configuration"); } diff --git a/source4/kdc/hdb-ldb.c b/source4/kdc/hdb-ldb.c index e1d7b7a184..cea7490ab8 100644 --- a/source4/kdc/hdb-ldb.c +++ b/source4/kdc/hdb-ldb.c @@ -524,7 +524,7 @@ static krb5_error_code LDB_lookup_realm(krb5_context context, struct ldb_context int ret; char *cross_ref_filter; struct ldb_result *cross_ref_res; - const struct ldb_dn *partitions_basedn = ldb_dn_string_compose(mem_ctx, samdb_base_dn(mem_ctx), "CN=Partitions,CN=Configuration"); + const struct ldb_dn *partitions_basedn = samdb_partitions_dn(ldb_ctx, mem_ctx); cross_ref_filter = talloc_asprintf(mem_ctx, "(&(&(|(&(dnsRoot=%s)(nETBIOSName=*))(nETBIOSName=%s))(objectclass=crossRef))(ncName=*))", @@ -706,7 +706,7 @@ static krb5_error_code LDB_fetch_server(krb5_context context, HDB *db, const char *realm; struct ldb_message **msg = NULL; struct ldb_message **realm_ref_msg = NULL; - const struct ldb_dn *partitions_basedn = ldb_dn_string_compose(mem_ctx, samdb_base_dn(mem_ctx), "CN=Partitions,CN=Configuration"); + const struct ldb_dn *partitions_basedn = samdb_partitions_dn(db->hdb_db, mem_ctx); if (principal->name.name_string.len >= 2) { /* 'normal server' case */ int ldb_ret; diff --git a/source4/nbt_server/dgram/netlogon.c b/source4/nbt_server/dgram/netlogon.c index 2a600120d1..e4cc4c966b 100644 --- a/source4/nbt_server/dgram/netlogon.c +++ b/source4/nbt_server/dgram/netlogon.c @@ -109,7 +109,7 @@ static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot, int ret; const char **services = lp_server_services(); const char *my_ip = reply_iface->ip_address; - const struct ldb_dn *partitions_basedn = ldb_dn_string_compose(packet, samdb_base_dn(packet), "CN=Partitions,CN=Configuration"); + const struct ldb_dn *partitions_basedn; if (!my_ip) { DEBUG(0, ("Could not obtain own IP address for datagram socket\n")); return; @@ -126,6 +126,8 @@ static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot, return; } + partitions_basedn = samdb_partitions_dn(samctx, samctx); + ret = gendb_search(samctx, samctx, partitions_basedn, &ref_res, ref_attrs, "(&(&(nETBIOSName=%s)(objectclass=crossRef))(ncName=*))", name->name); diff --git a/source4/rpc_server/dssetup/dcesrv_dssetup.c b/source4/rpc_server/dssetup/dcesrv_dssetup.c index 5d627c60fd..582b1f6071 100644 --- a/source4/rpc_server/dssetup/dcesrv_dssetup.c +++ b/source4/rpc_server/dssetup/dcesrv_dssetup.c @@ -101,7 +101,7 @@ static WERROR dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state domain = samdb_search_string(sam_ctx, mem_ctx, NULL, "nETBIOSName", "(&(objectclass=crossRef)(ncName=%s))", - ldb_dn_linearize(mem_ctx, samdb_base_dn(mem_ctx))); + ldb_dn_linearize(mem_ctx, samdb_base_dn(sam_ctx))); dns_domain = samdb_result_string(res[0], "dnsDomain", NULL); forest = samdb_result_string(res[0], "dnsDomain", NULL); diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c index 7949ee2a93..43bc91b149 100644 --- a/source4/rpc_server/lsa/dcesrv_lsa.c +++ b/source4/rpc_server/lsa/dcesrv_lsa.c @@ -267,7 +267,7 @@ static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_ struct lsa_policy_state **_state) { struct lsa_policy_state *state; - const struct ldb_dn *partitions_basedn = ldb_dn_string_compose(mem_ctx, samdb_base_dn(mem_ctx), "CN=Partitions,CN=Configuration"); + const struct ldb_dn *partitions_basedn; state = talloc(mem_ctx, struct lsa_policy_state); if (!state) { @@ -280,6 +280,8 @@ static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_ return NT_STATUS_INVALID_SYSTEM_SERVICE; } + partitions_basedn = samdb_partitions_dn(state->sam_ldb, mem_ctx); + state->sidmap = sidmap_open(state); if (state->sidmap == NULL) { return NT_STATUS_INVALID_SYSTEM_SERVICE; @@ -287,7 +289,7 @@ static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_ /* work out the domain_dn - useful for so many calls its worth fetching here */ - state->domain_dn = samdb_base_dn(state); + state->domain_dn = samdb_base_dn(state->sam_ldb); if (!state->domain_dn) { return NT_STATUS_NO_MEMORY; } diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c index 74a70e8bcf..dd6bdf3f6a 100644 --- a/source4/rpc_server/netlogon/dcerpc_netlogon.c +++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c @@ -889,7 +889,7 @@ static NTSTATUS netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_call, TALL struct netr_DomainInfo1 *info1; int ret, ret1, ret2, i; NTSTATUS status; - const struct ldb_dn *partitions_basedn = ldb_dn_string_compose(mem_ctx, samdb_base_dn(mem_ctx), "CN=Partitions,CN=Configuration"); + const struct ldb_dn *partitions_basedn = samdb_partitions_dn(sam_ctx, mem_ctx); const char *local_domain; @@ -1143,7 +1143,7 @@ static WERROR netr_DsrEnumerateDomainTrusts(struct dcesrv_call_state *dce_call, struct ldb_message **dom_res, **ref_res; const char * const dom_attrs[] = { "dnsDomain", "objectSid", "objectGUID", NULL }; const char * const ref_attrs[] = { "nETBIOSName", NULL }; - const struct ldb_dn *partitions_basedn = ldb_dn_string_compose(mem_ctx, samdb_base_dn(mem_ctx), "CN=Partitions,CN=Configuration"); + const struct ldb_dn *partitions_basedn = samdb_partitions_dn(sam_ctx, mem_ctx); ZERO_STRUCT(r->out); diff --git a/source4/rpc_server/samr/dcesrv_samr.c b/source4/rpc_server/samr/dcesrv_samr.c index 65a1491a1d..abbcb4818c 100644 --- a/source4/rpc_server/samr/dcesrv_samr.c +++ b/source4/rpc_server/samr/dcesrv_samr.c @@ -225,7 +225,7 @@ static NTSTATUS samr_LookupDomain(struct dcesrv_call_state *dce_call, TALLOC_CTX struct ldb_message **dom_msgs; struct ldb_message **ref_msgs; int ret; - const struct ldb_dn *partitions_basedn = ldb_dn_string_compose(mem_ctx, samdb_base_dn(mem_ctx), "CN=Partitions,CN=Configuration"); + const struct ldb_dn *partitions_basedn; r->out.sid = NULL; @@ -237,6 +237,8 @@ static NTSTATUS samr_LookupDomain(struct dcesrv_call_state *dce_call, TALLOC_CTX return NT_STATUS_INVALID_PARAMETER; } + partitions_basedn = samdb_partitions_dn(c_state->sam_ctx, mem_ctx); + if (strcasecmp(r->in.domain_name->string, "BUILTIN") == 0) { ret = gendb_search(c_state->sam_ctx, mem_ctx, NULL, &dom_msgs, dom_attrs, @@ -289,7 +291,7 @@ static NTSTATUS samr_EnumDomains(struct dcesrv_call_state *dce_call, TALLOC_CTX const char * const ref_attrs[] = { "nETBIOSName", NULL}; struct ldb_message **dom_msgs; struct ldb_message **ref_msgs; - const struct ldb_dn *partitions_basedn = ldb_dn_string_compose(mem_ctx, samdb_base_dn(mem_ctx), "CN=Partitions,CN=Configuration"); + const struct ldb_dn *partitions_basedn; *r->out.resume_handle = 0; r->out.sam = NULL; @@ -299,6 +301,8 @@ static NTSTATUS samr_EnumDomains(struct dcesrv_call_state *dce_call, TALLOC_CTX c_state = h->data; + partitions_basedn = samdb_partitions_dn(c_state->sam_ctx, mem_ctx); + count = gendb_search(c_state->sam_ctx, mem_ctx, NULL, &dom_msgs, dom_attrs, "(objectClass=domain)"); @@ -367,7 +371,7 @@ static NTSTATUS samr_OpenDomain(struct dcesrv_call_state *dce_call, TALLOC_CTX * struct ldb_message **dom_msgs; struct ldb_message **ref_msgs; int ret; - const struct ldb_dn *partitions_basedn = ldb_dn_string_compose(mem_ctx, samdb_base_dn(mem_ctx), "CN=Partitions,CN=Configuration"); + const struct ldb_dn *partitions_basedn; ZERO_STRUCTP(r->out.domain_handle); @@ -379,6 +383,8 @@ static NTSTATUS samr_OpenDomain(struct dcesrv_call_state *dce_call, TALLOC_CTX * return NT_STATUS_INVALID_PARAMETER; } + partitions_basedn = samdb_partitions_dn(c_state->sam_ctx, mem_ctx); + ret = gendb_search(c_state->sam_ctx, mem_ctx, NULL, &dom_msgs, dom_attrs, "(&(objectSid=%s)(&(objectclass=domain)))", |