From c37f290043c55ec6428a313b4ec3ca2f91e5e98e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 3 Sep 2009 18:27:29 +1000 Subject: added dsdb_find_guid_by_dn() This will be used by the linked_attribute module --- source4/dsdb/common/util.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'source4/dsdb/common') diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 32a8906884..0ffec8a7eb 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -2111,7 +2111,7 @@ int dsdb_find_dn_by_guid(struct ldb_context *ldb, partitions module that can return two here with the search_options control set */ if (res->count < 1) { - return LDB_ERR_OPERATIONS_ERROR; + return LDB_ERR_NO_SUCH_OBJECT; } *dn = res->msgs[0]->dn; @@ -2120,3 +2120,23 @@ int dsdb_find_dn_by_guid(struct ldb_context *ldb, } +/* + use a DN to find a GUID + */ +int dsdb_find_guid_by_dn(struct ldb_context *ldb, + struct ldb_dn *dn, struct GUID *guid) +{ + int ret; + struct ldb_result *res; + const char *attrs[] = { "objectGUID" }; + TALLOC_CTX *tmp_ctx = talloc_new(ldb); + + ret = ldb_search(ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE, attrs, NULL); + if (ret != LDB_SUCCESS) { + talloc_free(tmp_ctx); + return ret; + } + *guid = samdb_result_guid(res->msgs[0], "objectGUID"); + talloc_free(tmp_ctx); + return LDB_SUCCESS; +} -- cgit