summaryrefslogtreecommitdiff
path: root/source4/rpc_server/samr
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2005-06-14 19:15:17 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:18:11 -0500
commit9189833a8753a723a8b8d0af9c8b096571b06a84 (patch)
treed20481827bb51e1d2a6cddb2a7bcb64ff653b7a7 /source4/rpc_server/samr
parent056d63c62f3793fda0d3049a2f98cef435c9003e (diff)
downloadsamba-9189833a8753a723a8b8d0af9c8b096571b06a84.tar.gz
samba-9189833a8753a723a8b8d0af9c8b096571b06a84.tar.bz2
samba-9189833a8753a723a8b8d0af9c8b096571b06a84.zip
r7582: Better way to have a fast path searching for a specific DN.
Old way was ugly and had a bug, you couldn't add an attribute named dn or distinguishedName and search for it, tdb would change that search in a dn search. This makes it also possible to search by dn against an ldap server as the old method was not supported by ldap syntaxes. sss (This used to be commit a614466dec2484a0d39bdfae53da822cfcf80926)
Diffstat (limited to 'source4/rpc_server/samr')
-rw-r--r--source4/rpc_server/samr/dcesrv_samr.c66
-rw-r--r--source4/rpc_server/samr/samr_password.c13
2 files changed, 36 insertions, 43 deletions
diff --git a/source4/rpc_server/samr/dcesrv_samr.c b/source4/rpc_server/samr/dcesrv_samr.c
index b40028b880..337c300203 100644
--- a/source4/rpc_server/samr/dcesrv_samr.c
+++ b/source4/rpc_server/samr/dcesrv_samr.c
@@ -343,8 +343,8 @@ static NTSTATUS samr_info_DomInfo1(struct samr_domain_state *state,
int ret;
struct ldb_message **res;
- ret = gendb_search(state->sam_ctx, mem_ctx, NULL, &res, attrs,
- "dn=%s", state->domain_dn);
+ ret = gendb_search_dn(state->sam_ctx, mem_ctx,
+ state->domain_dn , &res, attrs);
if (ret != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
@@ -373,8 +373,8 @@ static NTSTATUS samr_info_DomInfo2(struct samr_domain_state *state, TALLOC_CTX *
int ret;
struct ldb_message **res;
- ret = gendb_search(state->sam_ctx, mem_ctx, NULL, &res, attrs,
- "dn=%s", state->domain_dn);
+ ret = gendb_search_dn(state->sam_ctx, mem_ctx,
+ state->domain_dn , &res, attrs);
if (ret != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
@@ -527,10 +527,8 @@ static NTSTATUS samr_CreateDomainGroup(struct dcesrv_call_state *dce_call, TALLO
a_state->account_dn = talloc_steal(a_state, msg->dn);
/* retrieve the sidstring for the group just created */
- sidstr = samdb_search_string(d_state->sam_ctx, a_state, NULL,
- "objectSid",
- "dn=%s",
- msg->dn);
+ sidstr = samdb_search_string(d_state->sam_ctx, a_state,
+ msg->dn, "objectSid", NULL);
if (sidstr == NULL) {
return NT_STATUS_UNSUCCESSFUL;
}
@@ -759,10 +757,8 @@ static NTSTATUS samr_CreateUser2(struct dcesrv_call_state *dce_call, TALLOC_CTX
a_state->account_dn = talloc_steal(a_state, msg->dn);
/* retrieve the sidstring for the group just created */
- sidstr = samdb_search_string(d_state->sam_ctx, a_state, NULL,
- "objectSid",
- "dn=%s",
- msg->dn);
+ sidstr = samdb_search_string(d_state->sam_ctx, a_state,
+ msg->dn, "objectSid", NULL);
if (sidstr == NULL) {
return NT_STATUS_UNSUCCESSFUL;
}
@@ -965,10 +961,8 @@ static NTSTATUS samr_CreateDomAlias(struct dcesrv_call_state *dce_call, TALLOC_C
a_state->account_dn = talloc_steal(a_state, msg->dn);
/* retrieve the sidstring for the group just created */
- sidstr = samdb_search_string(d_state->sam_ctx, a_state, NULL,
- "objectSid",
- "dn=%s",
- msg->dn);
+ sidstr = samdb_search_string(d_state->sam_ctx, a_state,
+ msg->dn, "objectSid", NULL);
if (sidstr == NULL) {
return NT_STATUS_UNSUCCESSFUL;
}
@@ -1490,8 +1484,8 @@ static NTSTATUS samr_QueryGroupInfo(struct dcesrv_call_state *dce_call, TALLOC_C
a_state = h->data;
/* pull all the group attributes */
- ret = gendb_search(a_state->sam_ctx, mem_ctx, NULL, &res, attrs,
- "dn=%s", a_state->account_dn);
+ ret = gendb_search_dn(a_state->sam_ctx, mem_ctx,
+ a_state->account_dn, &res, attrs);
if (ret != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
@@ -1750,8 +1744,8 @@ static NTSTATUS samr_QueryGroupMember(struct dcesrv_call_state *dce_call, TALLOC
a_state = h->data;
/* pull the member attribute */
- ret = gendb_search(a_state->sam_ctx, mem_ctx, NULL, &res, attrs,
- "dn=%s", a_state->account_dn);
+ ret = gendb_search_dn(a_state->sam_ctx, mem_ctx,
+ a_state->account_dn, &res, attrs);
if (ret != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -1784,9 +1778,9 @@ static NTSTATUS samr_QueryGroupMember(struct dcesrv_call_state *dce_call, TALLOC
for (i=0; i<el->num_values; i++) {
struct ldb_message **res2;
const char * const attrs2[2] = { "objectSid", NULL };
- ret = gendb_search(a_state->sam_ctx, mem_ctx, NULL,
- &res2, attrs2, "dn=%s",
- (char *)el->values[i].data);
+ ret = gendb_search_dn(a_state->sam_ctx, mem_ctx,
+ (char *)el->values[i].data,
+ &res2, attrs2);
if (ret != 1)
return NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -1916,8 +1910,8 @@ static NTSTATUS samr_QueryAliasInfo(struct dcesrv_call_state *dce_call, TALLOC_C
a_state = h->data;
/* pull all the alias attributes */
- ret = gendb_search(a_state->sam_ctx, mem_ctx, NULL, &res, attrs,
- "dn=%s", a_state->account_dn);
+ ret = gendb_search_dn(a_state->sam_ctx, mem_ctx,
+ a_state->account_dn ,&res, attrs);
if (ret != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
@@ -2229,8 +2223,8 @@ static NTSTATUS samr_GetMembersInAlias(struct dcesrv_call_state *dce_call, TALLO
a_state = h->data;
d_state = a_state->domain_state;
- ret = gendb_search(d_state->sam_ctx, mem_ctx, NULL, &msgs, attrs,
- "dn=%s", a_state->account_dn);
+ ret = gendb_search_dn(d_state->sam_ctx, mem_ctx,
+ a_state->account_dn, &msgs, attrs);
if (ret != 1)
return NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -2252,9 +2246,9 @@ static NTSTATUS samr_GetMembersInAlias(struct dcesrv_call_state *dce_call, TALLO
for (i=0; i<el->num_values; i++) {
struct ldb_message **msgs2;
const char * const attrs2[2] = { "objectSid", NULL };
- ret = gendb_search(a_state->sam_ctx, mem_ctx, NULL,
- &msgs2, attrs2, "dn=%s",
- (char *)el->values[i].data);
+ ret = gendb_search_dn(a_state->sam_ctx, mem_ctx,
+ (char *)el->values[i].data,
+ &msgs2, attrs2);
if (ret != 1)
return NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -2391,8 +2385,8 @@ static NTSTATUS samr_QueryUserInfo(struct dcesrv_call_state *dce_call, TALLOC_CT
a_state = h->data;
/* pull all the user attributes */
- ret = gendb_search(a_state->sam_ctx, mem_ctx, NULL, &res, NULL,
- "dn=%s", a_state->account_dn);
+ ret = gendb_search_dn(a_state->sam_ctx, mem_ctx,
+ a_state->account_dn ,&res, NULL);
if (ret != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
@@ -3117,10 +3111,10 @@ static NTSTATUS samr_GetUserPwInfo(struct dcesrv_call_state *dce_call, TALLOC_CT
a_state = h->data;
- r->out.info.min_password_length = samdb_search_uint(a_state->sam_ctx, mem_ctx, 0, NULL, "minPwdLength",
- "dn=%s", a_state->domain_state->domain_dn);
- r->out.info.password_properties = samdb_search_uint(a_state->sam_ctx, mem_ctx, 0, NULL, "pwdProperties",
- "dn=%s", a_state->account_dn);
+ r->out.info.min_password_length = samdb_search_uint(a_state->sam_ctx, mem_ctx, 0,
+ a_state->domain_state->domain_dn, "minPwdLength", NULL);
+ r->out.info.password_properties = samdb_search_uint(a_state->sam_ctx, mem_ctx, 0,
+ a_state->account_dn, "pwdProperties", NULL);
return NT_STATUS_OK;
}
diff --git a/source4/rpc_server/samr/samr_password.c b/source4/rpc_server/samr/samr_password.c
index f5390cc1d5..e7f547bbf3 100644
--- a/source4/rpc_server/samr/samr_password.c
+++ b/source4/rpc_server/samr/samr_password.c
@@ -50,8 +50,8 @@ NTSTATUS samr_ChangePasswordUser(struct dcesrv_call_state *dce_call, TALLOC_CTX
a_state = h->data;
/* fetch the old hashes */
- ret = gendb_search(a_state->sam_ctx, mem_ctx, NULL, &res, attrs,
- "dn=%s", a_state->account_dn);
+ ret = gendb_search_dn(a_state->sam_ctx, mem_ctx,
+ a_state->account_dn, &res, attrs);
if (ret != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
@@ -400,9 +400,8 @@ NTSTATUS samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call,
return NT_STATUS_OK;
failed:
- ret = gendb_search(sam_ctx,
- mem_ctx, NULL, &res, dom_attrs,
- "dn=%s", domain_dn);
+ ret = gendb_search_dn(sam_ctx, mem_ctx,
+ domain_dn, &res, dom_attrs);
if (ret != 1) {
return status;
@@ -517,7 +516,7 @@ NTSTATUS samdb_set_password(void *ctx, TALLOC_CTX *mem_ctx,
unix_to_nt_time(&now_nt, now);
/* pull all the user parameters */
- count = gendb_search(ctx, mem_ctx, NULL, &res, user_attrs, "dn=%s", user_dn);
+ count = gendb_search_dn(ctx, mem_ctx, user_dn, &res, user_attrs);
if (count != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
@@ -533,7 +532,7 @@ NTSTATUS samdb_set_password(void *ctx, TALLOC_CTX *mem_ctx,
pwdLastSet = samdb_result_uint64(res[0], "pwdLastSet", 0);
/* pull the domain parameters */
- count = gendb_search(ctx, mem_ctx, NULL, &res, domain_attrs, "dn=%s", domain_dn);
+ count = gendb_search_dn(ctx, mem_ctx, domain_dn, &res, domain_attrs);
if (count != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}