summaryrefslogtreecommitdiff
path: root/source4/auth/sam.c
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2010-06-28 20:26:16 +0200
committerMatthias Dieter Wallnöfer <mdw@samba.org>2010-06-28 20:31:37 +0200
commitb6eb17eb1eb23461149b6c8cbefc41f5265a77d9 (patch)
treefe8732b34f002caaad204152b5c93f32a3e4868d /source4/auth/sam.c
parenta782eaa2fd6f9b7e7b1ebdab0e0b53e4123cca43 (diff)
downloadsamba-b6eb17eb1eb23461149b6c8cbefc41f5265a77d9.tar.gz
samba-b6eb17eb1eb23461149b6c8cbefc41f5265a77d9.tar.bz2
samba-b6eb17eb1eb23461149b6c8cbefc41f5265a77d9.zip
s4:auth/sam.c - "authsam_expand_nested_groups" - small performance improvement
We can save one search operation if "only_childs" is false and when we had no SID passed as extended DN component.
Diffstat (limited to 'source4/auth/sam.c')
-rw-r--r--source4/auth/sam.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/source4/auth/sam.c b/source4/auth/sam.c
index b26e5264a7..d0487ced01 100644
--- a/source4/auth/sam.c
+++ b/source4/auth/sam.c
@@ -304,7 +304,7 @@ NTSTATUS authsam_expand_nested_groups(struct ldb_context *sam_ctx,
struct ldb_dn *dn;
struct dom_sid sid;
TALLOC_CTX *tmp_ctx;
- struct ldb_result *res;
+ struct ldb_result *res = NULL;
NTSTATUS status;
const struct ldb_message_element *el;
@@ -343,8 +343,12 @@ NTSTATUS authsam_expand_nested_groups(struct ldb_context *sam_ctx,
}
if (only_childs) {
- ret = dsdb_search_dn(sam_ctx, tmp_ctx, &res, dn, attrs,
- DSDB_SEARCH_SHOW_EXTENDED_DN);
+ /* If we didn't get the SID as extended DN then we already have
+ * performed exactly this search. */
+ if (res == NULL) {
+ ret = dsdb_search_dn(sam_ctx, tmp_ctx, &res, dn, attrs,
+ DSDB_SEARCH_SHOW_EXTENDED_DN);
+ }
} else {
/* This is an O(n^2) linear search */
already_there = sids_contains_sid((const struct dom_sid**) *res_sids,