Revert "s4:prefer "samdb_*_dn" basedn calls over the "ldb_get_*_dn" functions"
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Tue, 13 Apr 2010 06:41:10 +0000 (08:41 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Tue, 13 Apr 2010 06:55:15 +0000 (08:55 +0200)
We should use the "ldb_get_*_basedn" calls since they are available in the LDB
library.

20 files changed:
source4/cldap_server/netlogon.c
source4/dsdb/common/util.c
source4/dsdb/kcc/kcc_topology.c
source4/dsdb/repl/drepl_ridalloc.c
source4/dsdb/samdb/cracknames.c
source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
source4/dsdb/samdb/ldb_modules/rootdse.c
source4/dsdb/samdb/ldb_modules/samldb.c
source4/dsdb/samdb/ldb_modules/schema_load.c
source4/dsdb/samdb/ldb_modules/util.c
source4/dsdb/schema/schema_info_attr.c
source4/dsdb/schema/schema_init.c
source4/libnet/libnet_become_dc.c
source4/ntp_signd/ntp_signd.c
source4/rpc_server/drsuapi/getncchanges.c
source4/rpc_server/lsa/lsa_init.c
source4/rpc_server/netlogon/dcerpc_netlogon.c
source4/torture/drs/unit/prefixmap_tests.c
source4/torture/drs/unit/schemainfo_tests.c
source4/torture/ldap/uptodatevector.c

index 95fff1a8c6fa5831d749e5be8ffea916dcebb836..e6a4ab373c2e32df1b32426536638a19b80764bd 100644 (file)
@@ -233,7 +233,7 @@ NTSTATUS fill_netlogon_samlogon_response(struct ldb_context *sam_ctx,
 
 #if 0
        /* w2k8-r2 as a sole DC does not claim this */
-       if (ldb_dn_compare(samdb_root_dn(sam_ctx), samdb_base_dn(sam_ctx)) == 0) {
+       if (ldb_dn_compare(ldb_get_root_basedn(sam_ctx), ldb_get_default_basedn(sam_ctx)) == 0) {
                server_type |= DS_DNS_FOREST_ROOT;
        }
 #endif
index c6870da234b2cbe449beebed1032ce5aad7de317..fd98fd8e549747d31f1c8478b3b035835690ccf9 100644 (file)
@@ -1061,7 +1061,7 @@ struct ldb_dn *samdb_partitions_dn(struct ldb_context *sam_ctx, TALLOC_CTX *mem_
 {
        struct ldb_dn *new_dn;
 
-       new_dn = ldb_dn_copy(mem_ctx, samdb_config_dn(sam_ctx));
+       new_dn = ldb_dn_copy(mem_ctx, ldb_get_config_basedn(sam_ctx));
        if ( ! ldb_dn_add_child_fmt(new_dn, "CN=Partitions")) {
                talloc_free(new_dn);
                return NULL;
@@ -1073,7 +1073,7 @@ struct ldb_dn *samdb_infrastructure_dn(struct ldb_context *sam_ctx, TALLOC_CTX *
 {
        struct ldb_dn *new_dn;
 
-       new_dn = ldb_dn_copy(mem_ctx, samdb_base_dn(sam_ctx));
+       new_dn = ldb_dn_copy(mem_ctx, ldb_get_default_basedn(sam_ctx));
        if ( ! ldb_dn_add_child_fmt(new_dn, "CN=Infrastructure")) {
                talloc_free(new_dn);
                return NULL;
@@ -1085,7 +1085,7 @@ struct ldb_dn *samdb_sites_dn(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx)
 {
        struct ldb_dn *new_dn;
 
-       new_dn = ldb_dn_copy(mem_ctx, samdb_config_dn(sam_ctx));
+       new_dn = ldb_dn_copy(mem_ctx, ldb_get_config_basedn(sam_ctx));
        if ( ! ldb_dn_add_child_fmt(new_dn, "CN=Sites")) {
                talloc_free(new_dn);
                return NULL;
@@ -1541,7 +1541,8 @@ int samdb_server_reference_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, stru
  */
 int samdb_rid_manager_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_dn **dn)
 {
-       return samdb_reference_dn(ldb, mem_ctx, samdb_base_dn(ldb), "rIDManagerReference", dn);
+       return samdb_reference_dn(ldb, mem_ctx, ldb_get_default_basedn(ldb),
+                                 "rIDManagerReference", dn);
 }
 
 /*
@@ -2117,7 +2118,8 @@ NTSTATUS samdb_create_foreign_security_principal(struct ldb_context *sam_ctx, TA
                return NT_STATUS_NO_MEMORY;
        }
 
-       ret = dsdb_wellknown_dn(sam_ctx, sidstr, samdb_base_dn(sam_ctx),
+       ret = dsdb_wellknown_dn(sam_ctx, sidstr,
+                               ldb_get_default_basedn(sam_ctx),
                                DS_GUID_FOREIGNSECURITYPRINCIPALS_CONTAINER,
                                &basedn);
        if (ret != LDB_SUCCESS) {
@@ -3014,7 +3016,7 @@ int dsdb_get_deleted_objects_dn(struct ldb_context *ldb,
 int dsdb_tombstone_lifetime(struct ldb_context *ldb, uint32_t *lifetime)
 {
        struct ldb_dn *dn;
-       dn = samdb_config_dn(ldb);
+       dn = ldb_get_config_basedn(ldb);
        if (!dn) {
                return LDB_ERR_NO_SUCH_OBJECT;
        }
index 0b251b781b18f439ad969c402beb5c27ce7fa806..72eb5e1137b4050be06e89ad8db272a1215e42f1 100644 (file)
@@ -1113,7 +1113,7 @@ static NTSTATUS kcctpl_get_all_bridgehead_dcs(struct ldb_context *ldb,
        }
        site = res->msgs[0];
 
-       schemas_dn = samdb_schema_dn(ldb);
+       schemas_dn = ldb_get_schema_basedn(ldb);
        if (!schemas_dn) {
                DEBUG(1, (__location__ ": failed to find our own Schemas DN\n"));
 
index 43fc5a2c5176ac531929dd9187b39fdfb75a0693..2baf555d3ca1629f9d564264c5339c5598790536 100644 (file)
@@ -50,7 +50,7 @@ static WERROR drepl_create_rid_manager_source_dsa(struct dreplsrv_service *servi
                return WERR_NOMEM;
        }
 
-       sdsa->partition->dn = samdb_base_dn(ldb);
+       sdsa->partition->dn = ldb_get_default_basedn(ldb);
        sdsa->partition->nc.dn = ldb_dn_alloc_linearized(sdsa->partition, rid_manager_dn);
        ret = dsdb_find_guid_by_dn(ldb, rid_manager_dn, &sdsa->partition->nc.guid);
        if (ret != LDB_SUCCESS) {
index bce00bdb9def049360ce1e13f16e97b5ab8287ad..5a807f843193c38364a7b6b336aad924c7a64c52 100644 (file)
@@ -99,7 +99,7 @@ static enum drsuapi_DsNameStatus LDB_lookup_spn_alias(krb5_context context, stru
        }
 
        service_dn = ldb_dn_new(tmp_ctx, ldb_ctx, "CN=Directory Service,CN=Windows NT,CN=Services");
-       if ( ! ldb_dn_add_base(service_dn, samdb_config_dn(ldb_ctx))) {
+       if ( ! ldb_dn_add_base(service_dn, ldb_get_config_basedn(ldb_ctx))) {
                return DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR;
        }
        service_dn_str = ldb_dn_alloc_linearized(tmp_ctx, service_dn);
@@ -817,7 +817,7 @@ static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_
                        search_dn = samdb_result_dn(sam_ctx, mem_ctx, domain_res->msgs[0], "ncName", NULL);
                } else {
                        dsdb_flags = DSDB_SEARCH_SEARCH_ALL_PARTITIONS;
-                       search_dn = samdb_root_dn(sam_ctx);
+                       search_dn = ldb_get_root_basedn(sam_ctx);
                }
 
                /* search with the 'phantom root' flag */
index 00d9a30fd3d0dab43d4d5bbd3e376e39aec37c6a..0c5afd8e9c0fa7667887204e54af7a4c59a155ae 100644 (file)
@@ -50,7 +50,7 @@ static int pdc_fsmo_init(struct ldb_module *module)
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       pdc_dn = samdb_base_dn(ldb);
+       pdc_dn = ldb_get_default_basedn(ldb);
        if (!pdc_dn) {
                ldb_debug(ldb, LDB_DEBUG_WARNING,
                          "pdc_fsmo_init: no domain dn present: (skip loading of domain details)\n");
index e99fcaa5169e3d9407a2668557c629426ce4c9d3..d18e41c294091aeb439b9331ec74702178b20f24 100644 (file)
@@ -288,7 +288,7 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
                const char *dn_str;
 
                if (schema && schema->fsmo.we_are_master) {
-                       dn_str = ldb_dn_get_linearized(samdb_schema_dn(ldb));
+                       dn_str = ldb_dn_get_linearized(ldb_get_schema_basedn(ldb));
                        if (dn_str && dn_str[0]) {
                                if (ldb_msg_add_fmt(msg, "validFSMOs", "%s", dn_str) != 0) {
                                        goto failed;
@@ -310,7 +310,7 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
                pdc_fsmo = talloc_get_type(ldb_get_opaque(ldb, "dsdb_pdc_fsmo"),
                                           struct dsdb_pdc_fsmo);
                if (pdc_fsmo && pdc_fsmo->we_are_master) {
-                       dn_str = ldb_dn_get_linearized(samdb_base_dn(ldb));
+                       dn_str = ldb_dn_get_linearized(ldb_get_default_basedn(ldb));
                        if (dn_str && dn_str[0]) {
                                if (ldb_msg_add_fmt(msg, "validFSMOs", "%s", dn_str) != 0) {
                                        goto failed;
@@ -937,7 +937,7 @@ static int rootdse_schemaupdatenow(struct ldb_module *module, struct ldb_request
        int ret;
        struct ldb_dn *schema_dn;
 
-       schema_dn = samdb_schema_dn(ldb);
+       schema_dn = ldb_get_schema_basedn(ldb);
        if (!schema_dn) {
                ldb_reset_err_string(ldb);
                ldb_debug(ldb, LDB_DEBUG_WARNING,
index 3b2d283006ff0e25a387114acbedd0baf53acf19..c3a95f161861cc63ca9f0b280fa90f0cc5c068e3 100644 (file)
@@ -257,7 +257,8 @@ static int samldb_check_samAccountName(struct samldb_ctx *ac)
        }
 
        ret = ldb_build_search_req(&req, ldb, ac,
-                                  samdb_base_dn(ldb), LDB_SCOPE_SUBTREE,
+                                  ldb_get_default_basedn(ldb),
+                                  LDB_SCOPE_SUBTREE,
                                   filter, NULL,
                                   NULL,
                                   ac, samldb_check_samAccountName_callback,
index 50f6888564897355c0589c181c8f4f2a4a831f0f..b4a68769e63fbf4a664b50e65f40dcce4e15696d 100644 (file)
@@ -281,7 +281,7 @@ static int schema_load_init(struct ldb_module *module)
                return LDB_SUCCESS;
        }
 
-       schema_dn = samdb_schema_dn(ldb);
+       schema_dn = ldb_get_schema_basedn(ldb);
        if (!schema_dn) {
                ldb_reset_err_string(ldb);
                ldb_debug(ldb, LDB_DEBUG_WARNING,
index e95777462b67a86741d52dc52dea161c1dea562f..fe0ff7510ba88535b923726957a3e76b5442f02f 100644 (file)
@@ -528,7 +528,7 @@ int dsdb_module_reference_dn(struct ldb_module *module, TALLOC_CTX *mem_ctx, str
 int dsdb_module_rid_manager_dn(struct ldb_module *module, TALLOC_CTX *mem_ctx, struct ldb_dn **dn)
 {
        return dsdb_module_reference_dn(module, mem_ctx,
-                                       samdb_base_dn(ldb_module_get_ctx(module)),
+                                       ldb_get_default_basedn(ldb_module_get_ctx(module)),
                                        "rIDManagerReference", dn);
 }
 
index eee1c79b913123ffbcac512ad48cfc7ded122f49..165184739cbde822e24c8f0dfc3ecd8e47be7de8 100644 (file)
@@ -137,7 +137,7 @@ WERROR dsdb_module_schema_info_blob_read(struct ldb_module *ldb_module,
                NULL
        };
 
-       schema_dn = samdb_schema_dn(ldb_module_get_ctx(ldb_module));
+       schema_dn = ldb_get_schema_basedn(ldb_module_get_ctx(ldb_module));
        if (!schema_dn) {
                DEBUG(0,("dsdb_module_schema_info_blob_read: no schema dn present!\n"));
                return WERR_INTERNAL_DB_CORRUPTION;
@@ -184,7 +184,7 @@ static WERROR _dsdb_schema_info_write_prepare(struct ldb_context *ldb,
        struct ldb_dn *schema_dn;
        struct ldb_message_element *return_el;
 
-       schema_dn = samdb_schema_dn(ldb);
+       schema_dn = ldb_get_schema_basedn(ldb);
        if (!schema_dn) {
                DEBUG(0,("_dsdb_schema_info_write_prepare: no schema dn present\n"));
                return WERR_INTERNAL_DB_CORRUPTION;
index eb3400cedc69519ea3168f3149c5c7ad50dc1f86..3405e155d3dafcde32609b7731f751a5db0c625a 100644 (file)
@@ -266,7 +266,7 @@ WERROR dsdb_write_prefixes_from_schema_to_ldb(TALLOC_CTX *mem_ctx, struct ldb_co
        TALLOC_CTX *temp_ctx;
        struct drsuapi_DsReplicaOIDMapping_Ctr *ctr;
 
-       schema_dn = samdb_schema_dn(ldb);
+       schema_dn = ldb_get_schema_basedn(ldb);
        if (!schema_dn) {
                DEBUG(0,("dsdb_write_prefixes_from_schema_to_ldb: no schema dn present\n"));
                return WERR_FOOBAR;
@@ -334,7 +334,7 @@ WERROR dsdb_read_prefixes_from_ldb(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
                NULL
        };
 
-       schema_dn = samdb_schema_dn(ldb);
+       schema_dn = ldb_get_schema_basedn(ldb);
        if (!schema_dn) {
                DEBUG(0,("dsdb_read_prefixes_from_ldb: no schema dn present\n"));
                return WERR_FOOBAR;
index 486416e1bd71a921311d2638a12a3612b3c34466..2220e00597a7a7823186f5cfcbfa369af8430ee8 100644 (file)
@@ -1057,7 +1057,8 @@ static NTSTATUS becomeDC_ldap1_infrastructure_fsmo(struct libnet_BecomeDC_state
                NULL
        };
 
-       ret = dsdb_wellknown_dn(s->ldap1.ldb, s, samdb_base_dn(s->ldap1.ldb),
+       ret = dsdb_wellknown_dn(s->ldap1.ldb, s,
+                               ldb_get_default_basedn(s->ldap1.ldb),
                                DS_GUID_INFRASTRUCTURE_CONTAINER,
                                &basedn);
        if (ret != LDB_SUCCESS) {
@@ -3060,7 +3061,8 @@ static NTSTATUS becomeDC_ldap2_move_computer(struct libnet_BecomeDC_state *s)
        struct ldb_dn *old_dn;
        struct ldb_dn *new_dn;
 
-       ret = dsdb_wellknown_dn(s->ldap2.ldb, s, samdb_base_dn(s->ldap2.ldb),
+       ret = dsdb_wellknown_dn(s->ldap2.ldb, s,
+                               ldb_get_default_basedn(s->ldap2.ldb),
                                DS_GUID_DOMAIN_CONTROLLERS_CONTAINER,
                                &new_dn);
        if (ret != LDB_SUCCESS) {
index a2d14ad9181bb15678c5f2e4b98cf99285f7e5b7..cc135397bbcc31c0254bfba904b81ea327b11750 100644 (file)
@@ -163,7 +163,7 @@ static NTSTATUS ntp_signd_process(struct ntp_signd_connection *ntp_signd_conn,
 
        ret = ldb_search(ntp_signd_conn->ntp_signd->samdb, mem_ctx,
                                 &res,
-                                samdb_base_dn(ntp_signd_conn->ntp_signd->samdb),
+                                ldb_get_default_basedn(ntp_signd_conn->ntp_signd->samdb),
                                 LDB_SCOPE_SUBTREE,
                                 attrs,
                                 "(&(objectSid=%s)(objectClass=user))",
index 76b92db377fda14154183d2cf689f1b22ad7cd59..e70e863c368004796788d9a1c38ab7bb2e35faf2 100644 (file)
@@ -625,7 +625,7 @@ static WERROR getncchanges_rid_alloc(struct drsuapi_bind_state *b_state,
 
        talloc_free(ext_res);
 
-       base_dn = samdb_base_dn(ldb);
+       base_dn = ldb_get_default_basedn(ldb);
 
        DEBUG(2,("Allocated RID pool for server %s\n",
                 GUID_string(mem_ctx, &req8->destination_dsa_guid)));
@@ -752,7 +752,7 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_
        case DRSUAPI_EXOP_FSMO_RID_ALLOC:
                werr = getncchanges_rid_alloc(b_state, mem_ctx, req8, &r->out.ctr->ctr6);
                W_ERROR_NOT_OK_RETURN(werr);
-               search_dn = samdb_base_dn(b_state->sam_ctx);
+               search_dn = ldb_get_default_basedn(b_state->sam_ctx);
                break;
 
        case DRSUAPI_EXOP_FSMO_REQ_ROLE:
index 1fadee07f0cf833d8e65079bdda7dd750c5ab81c..486faaacf1dddb5343232657cbb5e43eeeca8b6a 100644 (file)
@@ -56,14 +56,14 @@ NTSTATUS dcesrv_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->sam_ldb);
+       state->domain_dn = ldb_get_default_basedn(state->sam_ldb);
        if (!state->domain_dn) {
                return NT_STATUS_NO_MEMORY;             
        }
 
        /* work out the forest root_dn - useful for so many calls its worth
           fetching here */
-       state->forest_dn = samdb_root_dn(state->sam_ldb);
+       state->forest_dn = ldb_get_root_basedn(state->sam_ldb);
        if (!state->forest_dn) {
                return NT_STATUS_NO_MEMORY;             
        }
index bb9d6b8399dc22de2701c17569bd8e43e14c6fa7..3fa5c69aeade905e1fa524bd45d2016e4b32d555 100644 (file)
@@ -1124,7 +1124,7 @@ static NTSTATUS fill_one_domain_info(TALLOC_CTX *mem_ctx,
        } else {
                char *p;
                /* TODO: we need a common function for pulling the forest */
-               info->dns_forestname.string = ldb_dn_canonical_string(info, samdb_root_dn(sam_ctx));
+               info->dns_forestname.string = ldb_dn_canonical_string(info, ldb_get_root_basedn(sam_ctx));
                if (!info->dns_forestname.string) {
                        return NT_STATUS_NO_SUCH_DOMAIN;
                }
@@ -1236,7 +1236,8 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_cal
                 * Check that the DNS hostname when it should be updated
                 * will be used only by maximum one host.
                 */
-               ret = gendb_search(sam_ctx, mem_ctx, samdb_base_dn(sam_ctx),
+               ret = gendb_search(sam_ctx, mem_ctx,
+                                  ldb_get_default_basedn(sam_ctx),
                                   &res0, attrs3, "(dNSHostName=%s)",
                                   r->in.query->workstation_info->dns_hostname);
                if (ret < 0) {
@@ -1349,7 +1350,7 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_cal
                   primary domain is also a "trusted" domain, so we need to
                   put the primary domain into the lists of returned trusts as
                   well. */
-               ret = gendb_search_dn(sam_ctx, mem_ctx, samdb_base_dn(sam_ctx),
+               ret = gendb_search_dn(sam_ctx, mem_ctx, ldb_get_default_basedn(sam_ctx),
                        &res2, attrs);
                if (ret != 1) {
                        return NT_STATUS_INTERNAL_DB_CORRUPTION;
index decd68057c35da62bff63a3888a5001fa86485c1..4282e26a6c7814637e89719760f999b17a1a61ce 100644 (file)
@@ -695,7 +695,7 @@ static bool torture_drs_unit_ldb_setup(struct torture_context *tctx, struct drsu
        /* add prefixMap attribute so tested layer could work properly */
        {
                struct ldb_message *msg = ldb_msg_new(mem_ctx);
-               msg->dn = samdb_schema_dn(priv->ldb_ctx);
+               msg->dn = ldb_get_schema_basedn(priv->ldb_ctx);
                ldb_err = ldb_msg_add_string(msg, "prefixMap", "prefixMap");
                torture_assert_int_equal_goto(tctx, ldb_err, LDB_SUCCESS, bret, DONE,
                                              "ldb_msg_add_empty() failed");
index 7928855fb3e726d2307e64b847017d7b86fbd858..c3bb56fd97270c516badb8874e0915c826744c9c 100644 (file)
@@ -383,7 +383,7 @@ static bool _drsut_ldb_schema_info_reset(struct torture_context *tctx,
        msg = ldb_msg_new(mem_ctx);
        torture_assert_goto(tctx, msg, bret, DONE, "Not enough memory!");
 
-       msg->dn = samdb_schema_dn(ldb);
+       msg->dn = ldb_get_schema_basedn(ldb);
        ldb_err = ldb_msg_add_value(msg, "schemaInfo", &blob, NULL);
        torture_assert_int_equal_goto(tctx, ldb_err, LDB_SUCCESS, bret, DONE,
                                      "ldb_msg_add_value() failed");
index a4ca7e535769f763d73883d3e5b1e6d4c7124627..0921cf779be8c92cedc679f6f5ec2e8d44897e14 100644 (file)
@@ -162,9 +162,9 @@ bool torture_ldap_uptodatevector(struct torture_context *torture)
                               0);
        if (!ldb) goto failed;
 
-       ret &= test_check_uptodatevector(torture, ldb, samdb_base_dn(ldb));
-       ret &= test_check_uptodatevector(torture, ldb, samdb_config_dn(ldb));
-       ret &= test_check_uptodatevector(torture, ldb, samdb_schema_dn(ldb));
+       ret &= test_check_uptodatevector(torture, ldb, ldb_get_default_basedn(ldb));
+       ret &= test_check_uptodatevector(torture, ldb, ldb_get_config_basedn(ldb));
+       ret &= test_check_uptodatevector(torture, ldb, ldb_get_schema_basedn(ldb));
 
        return ret;
 failed: