s4:dsdb Use the 'correct' case for the namingContext values in rootDSE
authorAndrew Bartlett <abartlet@samba.org>
Wed, 21 Oct 2009 22:45:14 +0000 (09:45 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 21 Oct 2009 22:45:14 +0000 (09:45 +1100)
This makes the namingContext attributes in the rootDSE a little more pretty, by
using the exact same values as used in the database DNs.

Andrew Bartlett

source4/dsdb/samdb/ldb_modules/partition_init.c

index c88d418783f476098e69a42bbe46c00d6a92a84d..f4163dab3d4e7a390403d4b31dc6f5c34c725c69 100644 (file)
@@ -394,6 +394,9 @@ int partition_reload_if_required(struct ldb_module *module,
                DATA_BLOB dn_blob;
                struct ldb_dn *dn;
                struct dsdb_partition *partition;
+               struct ldb_result *dn_res;
+               const char *no_attrs[] = { NULL };
+
                for (j=0; data->partitions && data->partitions[j]; j++) {
                        DATA_BLOB casefold = data_blob_string_const(ldb_dn_get_casefold(data->partitions[j]->ctrl->dn));
                        if (data_blob_cmp(&casefold, &partition_attributes->values[i]) == 0) {
@@ -451,6 +454,25 @@ int partition_reload_if_required(struct ldb_module *module,
                        return ret;
                }
 
+               /* Get the 'correct' case of the partition DNs from the database */
+               ret = dsdb_module_search_dn(partition->module, data, &dn_res, 
+                                           dn, no_attrs);
+               if (ret == LDB_SUCCESS) {
+                       talloc_free(partition->ctrl->dn);
+                       partition->ctrl->dn = talloc_steal(partition->ctrl, dn_res->msgs[0]->dn);
+                       talloc_free(dn_res);
+               } else if (ret != LDB_ERR_NO_SUCH_OBJECT) {
+                       ldb_asprintf_errstring(ldb,
+                                              "Failed to search for %s from " DSDB_PARTITION_DN 
+                                              " replicateEntries for new partition at %s on %s: %s", 
+                                              ldb_dn_get_linearized(data->replicate[i]), 
+                                              partition->backend_url,
+                                              ldb_dn_get_linearized(partition->ctrl->dn), 
+                                              ldb_errstring(ldb));
+                       talloc_free(mem_ctx);
+                       return ret;
+               }
+
                ret = add_partition_to_data(ldb, data, partition);
                if (ret != LDB_SUCCESS) {
                        talloc_free(mem_ctx);