diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/auth/auth_sam.c | 51 |
1 files changed, 18 insertions, 33 deletions
diff --git a/source4/auth/auth_sam.c b/source4/auth/auth_sam.c index 6003cfd415..9872031653 100644 --- a/source4/auth/auth_sam.c +++ b/source4/auth/auth_sam.c @@ -56,22 +56,7 @@ static NTSTATUS authsam_search_account(TALLOC_CTX *mem_ctx, struct ldb_context * if (domain_name) { domain_dn = samdb_domain_to_dn(sam_ctx, mem_ctx, domain_name); - - /* find the domain's DN */ - ret_domain = gendb_search_dn(sam_ctx, mem_ctx, domain_dn, &msgs_domain_ref, domain_ref_attrs); - if (ret_domain == -1) { - return NT_STATUS_INTERNAL_DB_CORRUPTION; - } - - if (ret_domain == 0) { - DEBUG(3,("sam_search_user: Couldn't find domain [%s] in samdb.\n", - domain_name)); - return NT_STATUS_NO_SUCH_USER; - } - - if (ret_domain > 1) { - DEBUG(0,("Found %d records matching domain [%s]\n", - ret_domain, domain_name)); + if (!domain_dn) { return NT_STATUS_INTERNAL_DB_CORRUPTION; } } @@ -95,7 +80,7 @@ static NTSTATUS authsam_search_account(TALLOC_CTX *mem_ctx, struct ldb_context * return NT_STATUS_INTERNAL_DB_CORRUPTION; } - if (!domain_name) { + if (!domain_dn) { struct dom_sid *domain_sid; domain_sid = samdb_result_sid_prefix(mem_ctx, msgs[0], "objectSid"); @@ -123,25 +108,25 @@ static NTSTATUS authsam_search_account(TALLOC_CTX *mem_ctx, struct ldb_context * return NT_STATUS_INTERNAL_DB_CORRUPTION; } - ret_domain = gendb_search(sam_ctx, mem_ctx, partitions_basedn, &msgs_domain_ref, domain_ref_attrs, - "(nCName=%s)", ldb_dn_alloc_linearized(msgs_tmp, msgs_tmp[0]->dn)); + domain_dn = msgs_tmp[0]->dn; + } - if (ret_domain == -1) { - return NT_STATUS_INTERNAL_DB_CORRUPTION; - } + ret_domain = gendb_search(sam_ctx, mem_ctx, partitions_basedn, &msgs_domain_ref, domain_ref_attrs, + "(nCName=%s)", ldb_dn_alloc_linearized(msgs_tmp, domain_dn)); + if (ret_domain == -1) { + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } - if (ret_domain == 0) { - DEBUG(3,("check_sam_security: Couldn't find domain [%s] in passdb file.\n", - ldb_dn_get_linearized(msgs_tmp[0]->dn))); - return NT_STATUS_NO_SUCH_USER; - } + if (ret_domain == 0) { + DEBUG(3,("check_sam_security: Couldn't find domain [%s] in passdb file.\n", + ldb_dn_get_linearized(msgs_tmp[0]->dn))); + return NT_STATUS_NO_SUCH_USER; + } - if (ret_domain > 1) { - DEBUG(0,("Found %d records matching domain [%s]\n", - ret_domain, ldb_dn_get_linearized(msgs_tmp[0]->dn))); - return NT_STATUS_INTERNAL_DB_CORRUPTION; - } - + if (ret_domain > 1) { + DEBUG(0,("Found %d records matching domain [%s]\n", + ret_domain, ldb_dn_get_linearized(msgs_tmp[0]->dn))); + return NT_STATUS_INTERNAL_DB_CORRUPTION; } *ret_msgs = msgs; |