From 7d0fdcae1e68f24a642e1b0fb0069ec54502fbb9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 16 Dec 2009 13:18:44 +1100 Subject: s4-dsdb: added dsdb_wellknown_dn() This finds a wellknown object given its GUID Pair-Programmed-With: Andrew Bartlett --- source4/dsdb/common/util.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 30eb28c69c..1162196843 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -2750,3 +2750,35 @@ bool dsdb_dn_is_deleted_val(struct ldb_val *val) } return false; } + +/* + return a DN for a wellknown GUID + */ +int dsdb_wellknown_dn(struct ldb_context *samdb, TALLOC_CTX *mem_ctx, + struct ldb_dn *nc_root, const char *wk_guid, + struct ldb_dn **wkguid_dn) +{ + TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); + const char *attrs[] = { NULL }; + int ret; + struct ldb_dn *dn; + struct ldb_result *res; + + /* construct the magic WKGUID DN */ + dn = ldb_dn_new_fmt(tmp_ctx, samdb, "", + wk_guid, ldb_dn_get_linearized(nc_root)); + if (!wkguid_dn) { + talloc_free(tmp_ctx); + return LDB_ERR_OPERATIONS_ERROR; + } + + ret = dsdb_search_dn_with_deleted(samdb, tmp_ctx, &res, dn, attrs); + if (ret != LDB_SUCCESS) { + talloc_free(tmp_ctx); + return ret; + } + + (*wkguid_dn) = talloc_steal(mem_ctx, res->msgs[0]->dn); + talloc_free(tmp_ctx); + return LDB_SUCCESS; +} -- cgit