diff options
author | Stefan Metzmacher <metze@samba.org> | 2010-05-11 10:34:19 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2010-05-11 18:11:06 +0200 |
commit | 7e49fd92ca8dca87cc13fade08c1aa5d95df55a6 (patch) | |
tree | 181ab4842bc13832245e18099712b196762826ee /source4/dsdb | |
parent | b81887f2d97969d98023896c90ec8aa98f30242c (diff) | |
download | samba-7e49fd92ca8dca87cc13fade08c1aa5d95df55a6.tar.gz samba-7e49fd92ca8dca87cc13fade08c1aa5d95df55a6.tar.bz2 samba-7e49fd92ca8dca87cc13fade08c1aa5d95df55a6.zip |
s4:dsdb: cached results of samdb_rodc()
metze
Diffstat (limited to 'source4/dsdb')
-rw-r--r-- | source4/dsdb/common/util.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 5deb1d08b1..b9bff91eb8 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -2705,11 +2705,39 @@ int samdb_is_rodc(struct ldb_context *sam_ctx, const struct GUID *objectGUID, bo int samdb_rodc(struct ldb_context *sam_ctx, bool *am_rodc) { const struct GUID *objectGUID; + int ret; + bool *cached; + + /* see if we have a cached copy */ + cached = (bool *)ldb_get_opaque(sam_ctx, "cache.am_rodc"); + if (cached) { + *am_rodc = *cached; + return LDB_SUCCESS; + } + objectGUID = samdb_ntds_objectGUID(sam_ctx); if (!objectGUID) { return LDB_ERR_OPERATIONS_ERROR; } - return samdb_is_rodc(sam_ctx, objectGUID, am_rodc); + + ret = samdb_is_rodc(sam_ctx, objectGUID, am_rodc); + if (ret != LDB_SUCCESS) { + return ret; + } + + cached = talloc(sam_ctx, bool); + if (cached == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + *cached = *am_rodc; + + ret = ldb_set_opaque(sam_ctx, "cache.am_rodc", cached); + if (ret != LDB_SUCCESS) { + talloc_free(cached); + return LDB_ERR_OPERATIONS_ERROR; + } + + return LDB_SUCCESS; } |