diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-10-01 19:04:44 -0700 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-10-01 21:09:51 -0700 |
commit | ee15dc96926f505ba7f01ccfcfc2959b507f2b96 (patch) | |
tree | dd3ad0a514ee469340a9e534e61bd077f8456670 /source4/dsdb/common | |
parent | 76232a40d844dc37720e07ee0f2131526a1a6942 (diff) | |
download | samba-ee15dc96926f505ba7f01ccfcfc2959b507f2b96.tar.gz samba-ee15dc96926f505ba7f01ccfcfc2959b507f2b96.tar.bz2 samba-ee15dc96926f505ba7f01ccfcfc2959b507f2b96.zip |
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 <abartlet@samba.org>
Diffstat (limited to 'source4/dsdb/common')
-rw-r--r-- | source4/dsdb/common/util.c | 26 |
1 files changed, 26 insertions, 0 deletions
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 @@ -3760,6 +3760,32 @@ int dsdb_search_dn(struct ldb_context *ldb, } /* + 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=%s>", 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 */ int dsdb_search(struct ldb_context *ldb, |