From ee15dc96926f505ba7f01ccfcfc2959b507f2b96 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 1 Oct 2010 19:04:44 -0700 Subject: s4-dsdb: added dsdb_search_by_dn_guid() this is more efficient than first searching for the DN, then doing a search. We should look at using this in lots of existing code Pair-Programmed-With: Andrew Bartlett --- source4/dsdb/common/util.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source4/dsdb') diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 3259eabc3c..7e6090124b 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -3759,6 +3759,32 @@ int dsdb_search_dn(struct ldb_context *ldb, return LDB_SUCCESS; } +/* + search for attrs on one DN, by the GUID of the DN, allowing for + dsdb_flags controls + */ +int dsdb_search_by_dn_guid(struct ldb_context *ldb, + TALLOC_CTX *mem_ctx, + struct ldb_result **_res, + const struct GUID *guid, + const char * const *attrs, + uint32_t dsdb_flags) +{ + TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); + struct ldb_dn *dn; + int ret; + + dn = ldb_dn_new_fmt(tmp_ctx, ldb, "", GUID_string(tmp_ctx, guid)); + if (!ldb_dn_validate(dn)) { + talloc_free(tmp_ctx); + return LDB_ERR_INVALID_DN_SYNTAX; + } + + ret = dsdb_search_dn(ldb, mem_ctx, _res, dn, attrs, dsdb_flags); + talloc_free(tmp_ctx); + return ret; +} + /* general search with dsdb_flags for controls */ -- cgit