From b6eb17eb1eb23461149b6c8cbefc41f5265a77d9 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Mon, 28 Jun 2010 20:26:16 +0200 Subject: 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. --- source4/auth/sam.c | 10 +++++++--- 1 file 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, -- cgit