summaryrefslogtreecommitdiff
path: root/source4/dsdb/common
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-12-16 13:18:44 +1100
committerAndrew Tridgell <tridge@samba.org>2009-12-16 20:56:22 +1100
commit7d0fdcae1e68f24a642e1b0fb0069ec54502fbb9 (patch)
tree26681ff663cf6d5285b4c05450e83b82257b7ede /source4/dsdb/common
parentb7a74aca5e27213d1ff20b584c67a5bda407ce89 (diff)
downloadsamba-7d0fdcae1e68f24a642e1b0fb0069ec54502fbb9.tar.gz
samba-7d0fdcae1e68f24a642e1b0fb0069ec54502fbb9.tar.bz2
samba-7d0fdcae1e68f24a642e1b0fb0069ec54502fbb9.zip
s4-dsdb: added dsdb_wellknown_dn()
This finds a wellknown object given its GUID Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/dsdb/common')
-rw-r--r--source4/dsdb/common/util.c32
1 files changed, 32 insertions, 0 deletions
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, "<WKGUID=%s,%s>",
+ 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;
+}