diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-08-25 06:44:23 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:58:21 -0500 |
commit | ede02ee03867d2f6582c446fcab0882072baaa5a (patch) | |
tree | ea7e56a1b9f1552cc9752cf8736084555005518c /source4/rpc_server/samr/samr_password.c | |
parent | 294f6f16947c56d3fac5b24e5c95e8df522e18d6 (diff) | |
download | samba-ede02ee03867d2f6582c446fcab0882072baaa5a.tar.gz samba-ede02ee03867d2f6582c446fcab0882072baaa5a.tar.bz2 samba-ede02ee03867d2f6582c446fcab0882072baaa5a.zip |
r2051: switched the samdb over to using the new destructor and reference
count features of talloc, instead of re-implementing both those
features inside of samdb (which is what we did before).
This makes samdb considerably simpler, and also fixes some bugs, as I
found some error paths that didn't call samdb_close(). Those are now
handled by the fact that a talloc_free() will auto-close and destroy
the samdb context, using a destructor.
(This used to be commit da60987a92266734c33b81ee217081abdc4330f3)
Diffstat (limited to 'source4/rpc_server/samr/samr_password.c')
-rw-r--r-- | source4/rpc_server/samr/samr_password.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/source4/rpc_server/samr/samr_password.c b/source4/rpc_server/samr/samr_password.c index f1947022a2..852f564aef 100644 --- a/source4/rpc_server/samr/samr_password.c +++ b/source4/rpc_server/samr/samr_password.c @@ -145,7 +145,7 @@ NTSTATUS samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call, TALLOC_ /* this call doesn't take a policy handle, so we need to open the sam db from scratch */ - sam_ctx = samdb_connect(); + sam_ctx = samdb_connect(mem_ctx); if (sam_ctx == NULL) { return NT_STATUS_INVALID_SYSTEM_SERVICE; } @@ -158,7 +158,6 @@ NTSTATUS samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call, TALLOC_ "(&(sAMAccountName=%s)(objectclass=user))", r->in.account->name); if (ret != 1) { - samdb_close(sam_ctx); return NT_STATUS_NO_SUCH_USER; } @@ -177,21 +176,18 @@ NTSTATUS samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call, TALLOC_ if (!decode_pw_buffer(pwbuf->data, new_pass, sizeof(new_pass), &new_pass_len, STR_ASCII)) { DEBUG(3,("samr: failed to decode password buffer\n")); - samdb_close(sam_ctx); return NT_STATUS_WRONG_PASSWORD; } /* work out the domain dn */ domain_sid = samdb_result_sid_prefix(mem_ctx, res[0], "objectSid"); if (domain_sid == NULL) { - samdb_close(sam_ctx); return NT_STATUS_NO_SUCH_USER; } domain_dn = samdb_search_string(sam_ctx, mem_ctx, NULL, "dn", "(objectSid=%s)", domain_sid); if (!domain_dn) { - samdb_close(sam_ctx); return NT_STATUS_INTERNAL_DB_CORRUPTION; } @@ -199,7 +195,6 @@ NTSTATUS samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call, TALLOC_ ZERO_STRUCT(mod); mod.dn = talloc_strdup(mem_ctx, user_dn); if (!mod.dn) { - samdb_close(sam_ctx); return NT_STATUS_NO_MEMORY; } @@ -211,18 +206,15 @@ NTSTATUS samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call, TALLOC_ NULL, NULL, True, NULL); if (!NT_STATUS_IS_OK(status)) { - samdb_close(sam_ctx); return status; } /* modify the samdb record */ ret = samdb_replace(sam_ctx, mem_ctx, &mod); if (ret != 0) { - samdb_close(sam_ctx); return NT_STATUS_UNSUCCESSFUL; } - samdb_close(sam_ctx); return NT_STATUS_OK; } @@ -262,7 +254,7 @@ NTSTATUS samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call, /* this call doesn't take a policy handle, so we need to open the sam db from scratch */ - sam_ctx = samdb_connect(); + sam_ctx = samdb_connect(mem_ctx); if (sam_ctx == NULL) { status = NT_STATUS_INVALID_SYSTEM_SERVICE; goto failed; @@ -344,16 +336,12 @@ NTSTATUS samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call, goto failed; } - samdb_close(sam_ctx); return NT_STATUS_OK; failed: ret = samdb_search(sam_ctx, mem_ctx, NULL, &res, dom_attrs, "dn=%s", domain_dn); - if (sam_ctx) { - samdb_close(sam_ctx); - } if (ret != 1) { return status; |