mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
r17824: add a wrapper for the common partitions_basedn calculation
(This used to be commit 09007b0907
)
This commit is contained in:
parent
0fd9807942
commit
b21b119cbc
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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)))",
|
||||
|
@ -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;
|
||||
return ldb_auto_basedn(sam_ctx);
|
||||
}
|
||||
|
||||
if (!tmp_ctx) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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)))",
|
||||
|
Loading…
Reference in New Issue
Block a user