1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

ldb_tdb: Add a function to get the GUID key for a DN

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2017-08-11 18:09:01 +12:00
parent f26d1a8c5d
commit ccb9443664
2 changed files with 45 additions and 0 deletions

View File

@ -47,6 +47,10 @@ struct ltdb_idxptr {
static int ltdb_write_index_dn_guid(struct ldb_module *module,
const struct ldb_message *msg,
int add);
static int ltdb_index_dn_base_dn(struct ldb_module *module,
struct ltdb_private *ltdb,
struct ldb_dn *base_dn,
struct dn_list *dn_list);
/* we put a @IDXVERSION attribute on index entries. This
allows us to tell if it was written by an older version
@ -266,6 +270,42 @@ normal_index:
return LDB_SUCCESS;
}
int ltdb_key_dn_from_idx(struct ldb_module *module,
struct ltdb_private *ltdb,
TALLOC_CTX *mem_ctx,
struct ldb_dn *dn,
TDB_DATA *tdb_key)
{
struct ldb_context *ldb = ldb_module_get_ctx(module);
int ret;
struct dn_list *list = talloc(mem_ctx, struct dn_list);
if (list == NULL) {
ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
ret = ltdb_index_dn_base_dn(module, ltdb, dn, list);
if (ret != LDB_SUCCESS) {
return ret;
}
if (list->count == 0) {
return LDB_ERR_NO_SUCH_OBJECT;
}
if (list->count > 1) {
return LDB_ERR_CONSTRAINT_VIOLATION;
}
*tdb_key = ltdb_guid_to_key(module, ltdb,
mem_ctx, &list->dn[0]);
if (tdb_key->dptr == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
return LDB_SUCCESS;
}
/*
save a dn_list into a full @IDX style record

View File

@ -114,6 +114,11 @@ int ltdb_reindex(struct ldb_module *module);
int ltdb_index_transaction_start(struct ldb_module *module);
int ltdb_index_transaction_commit(struct ldb_module *module);
int ltdb_index_transaction_cancel(struct ldb_module *module);
int ltdb_key_dn_from_idx(struct ldb_module *module,
struct ltdb_private *ltdb,
TALLOC_CTX *mem_ctx,
struct ldb_dn *dn,
TDB_DATA *tdb_key);
/* The following definitions come from lib/ldb/ldb_tdb/ldb_search.c */