int ret;
struct extended_dn_out_private *p = talloc(module, struct extended_dn_out_private);
+ struct dsdb_extended_dn_store_format *dn_format;
ldb_module_set_private(module, p);
return LDB_ERR_OPERATIONS_ERROR;
}
+ dn_format = talloc(p, struct dsdb_extended_dn_store_format);
+ if (!dn_format) {
+ talloc_free(p);
+ ldb_oom(ldb_module_get_ctx(module));
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ dn_format->store_extended_dn_in_ldb = true;
+ ret = ldb_set_opaque(ldb_module_get_ctx(module), DSDB_EXTENDED_DN_STORE_FORMAT_OPAQUE_NAME, dn_format);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(p);
+ return ret;
+ }
+
p->dereference = false;
p->normalise = false;
{
int ret, i = 0;
struct extended_dn_out_private *p = talloc_zero(module, struct extended_dn_out_private);
+ struct dsdb_extended_dn_store_format *dn_format;
struct dsdb_openldap_dereference_control *dereference_control;
struct dsdb_attribute *cur;
struct ldb_context *ldb = ldb_module_get_ctx(module);
return LDB_ERR_OPERATIONS_ERROR;
}
+ dn_format = talloc(p, struct dsdb_extended_dn_store_format);
+ if (!dn_format) {
+ talloc_free(p);
+ ldb_oom(ldb_module_get_ctx(module));
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ dn_format->store_extended_dn_in_ldb = false;
+
+ ret = ldb_set_opaque(ldb_module_get_ctx(module), DSDB_EXTENDED_DN_STORE_FORMAT_OPAQUE_NAME, dn_format);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(p);
+ return ret;
+ }
+
p->dereference = true;
/* At the moment, servers that need dereference also need the
}
if (!ldb_msg_find_element(msg, "objectCategory")) {
- value = talloc_strdup(msg, current->objectclass->defaultObjectCategory);
+ struct dsdb_extended_dn_store_format *dn_format = talloc_get_type(ldb_module_get_private(ac->module), struct dsdb_extended_dn_store_format);
+ if (dn_format && dn_format->store_extended_dn_in_ldb == false) {
+ /* Strip off extended components */
+ struct ldb_dn *dn = ldb_dn_new(msg, ldb, current->objectclass->defaultObjectCategory);
+ value = ldb_dn_alloc_linearized(msg, dn);
+ talloc_free(dn);
+ } else {
+ value = talloc_strdup(msg, current->objectclass->defaultObjectCategory);
+ }
if (value == NULL) {
ldb_oom(ldb);
talloc_free(mem_ctx);
return ldb_next_request(ac->module, rename_req);
}
+static int objectclass_init(struct ldb_module *module)
+{
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
+ int ret;
+ /* Init everything else */
+ ret = ldb_next_init(module);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+
+ /* Look for the opaque to indicate we might have to cut down the DN of defaultObjectCategory */
+ ldb_module_set_private(module, ldb_get_opaque(ldb, DSDB_EXTENDED_DN_STORE_FORMAT_OPAQUE_NAME));
+
+ return ldb_next_init(module);
+}
+
_PUBLIC_ const struct ldb_module_ops ldb_objectclass_module_ops = {
.name = "objectclass",
.add = objectclass_add,
.modify = objectclass_modify,
.rename = objectclass_rename,
+ .init_context = objectclass_init
};
#include "libcli/ldap/ldap_ndr.h"
#include "ldb_module.h"
#include "dsdb/samdb/samdb.h"
+#include "dsdb/samdb/ldb_modules/util.h"
#include "libcli/security/security.h"
#include "librpc/gen_ndr/ndr_security.h"
#include "../lib/util/util_ldb.h"
if (ret != LDB_SUCCESS) {
return ret;
}
+ ret = dsdb_module_search_handle_flags(ac->module, req, DSDB_SEARCH_SHOW_DN_IN_STORAGE_FORMAT);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
return ldb_next_request(ac->module, req);
}
#define DSDB_PARTITION_DN "@PARTITION"
#define DSDB_PARTITION_ATTR "partition"
+#define DSDB_EXTENDED_DN_STORE_FORMAT_OPAQUE_NAME "dsdb_extended_dn_store_format"
+struct dsdb_extended_dn_store_format {
+ bool store_extended_dn_in_ldb;
+};
+
#endif /* __SAMDB_H__ */