diff options
author | Andrew Bartlett <abartlet@samba.org> | 2005-12-19 07:07:11 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:47:30 -0500 |
commit | bceca723044e9cf5d835e8d732be3ab57906505e (patch) | |
tree | b830194679166aa8a30285fd966a5f250c73f414 /source4/rpc_server | |
parent | 6bd8be867130686946e687512d7a4a68934217e1 (diff) | |
download | samba-bceca723044e9cf5d835e8d732be3ab57906505e.tar.gz samba-bceca723044e9cf5d835e8d732be3ab57906505e.tar.bz2 samba-bceca723044e9cf5d835e8d732be3ab57906505e.zip |
r12361: Add a new function: ldb_binary_encode_string()
This is for use on user-supplied arguments to printf style format
strings which will become ldb filters. I have used it on LSA, SAMR
and the auth/ code so far.
Also add comments to cracknames code.
Andrew Bartlett
(This used to be commit 8308cf6e0472790c1c9d521d19322557907f4418)
Diffstat (limited to 'source4/rpc_server')
-rw-r--r-- | source4/rpc_server/lsa/dcesrv_lsa.c | 16 | ||||
-rw-r--r-- | source4/rpc_server/samr/dcesrv_samr.c | 12 |
2 files changed, 16 insertions, 12 deletions
diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c index a0770764f5..64da9f488f 100644 --- a/source4/rpc_server/lsa/dcesrv_lsa.c +++ b/source4/rpc_server/lsa/dcesrv_lsa.c @@ -579,7 +579,7 @@ static NTSTATUS lsa_CreateTrustedDomain(struct dcesrv_call_state *dce_call, TALL ret = gendb_search(trusted_domain_state->policy->sam_ldb, mem_ctx, policy_state->system_dn, &msgs, attrs, "(&(cn=%s)(objectclass=trustedDomain))", - r->in.info->name.string); + ldb_binary_encode_string(mem_ctx, r->in.info->name.string)); if (ret > 0) { return NT_STATUS_OBJECT_NAME_COLLISION; } @@ -740,7 +740,7 @@ static NTSTATUS lsa_OpenTrustedDomainByName(struct dcesrv_call_state *dce_call, ret = gendb_search(trusted_domain_state->policy->sam_ldb, mem_ctx, policy_state->system_dn, &msgs, attrs, "(&(flatname=%s)(objectclass=trustedDomain))", - r->in.name.string); + ldb_binary_encode_string(mem_ctx, r->in.name.string)); if (ret == 0) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -1709,7 +1709,7 @@ static NTSTATUS lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX return NT_STATUS_INVALID_PARAMETER; } - name2 = talloc_asprintf(mem_ctx, "%s Secret", name); + name2 = talloc_asprintf(mem_ctx, "%s Secret", ldb_binary_encode_string(mem_ctx, name)); /* search for the secret record */ ret = gendb_search(secret_state->sam_ldb, mem_ctx, policy_state->system_dn, &msgs, attrs, @@ -1745,7 +1745,8 @@ static NTSTATUS lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX ret = gendb_search(secret_state->sam_ldb, mem_ctx, ldb_dn_explode(mem_ctx, "cn=LSA Secrets"), &msgs, attrs, - "(&(cn=%s)(objectclass=secret))", name); + "(&(cn=%s)(objectclass=secret))", + ldb_binary_encode_string(mem_ctx, name)); if (ret > 0) { return NT_STATUS_OBJECT_NAME_COLLISION; } @@ -1843,7 +1844,7 @@ static NTSTATUS lsa_OpenSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *m ret = gendb_search(secret_state->sam_ldb, mem_ctx, policy_state->system_dn, &msgs, attrs, "(&(cn=%s Secret)(objectclass=secret))", - name); + ldb_binary_encode_string(mem_ctx, name)); if (ret == 0) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -1867,7 +1868,8 @@ static NTSTATUS lsa_OpenSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *m ret = gendb_search(secret_state->sam_ldb, mem_ctx, ldb_dn_explode(mem_ctx, "cn=LSA Secrets"), &msgs, attrs, - "(&(cn=%s)(objectclass=secret))", name); + "(&(cn=%s)(objectclass=secret))", + ldb_binary_encode_string(mem_ctx, name)); if (ret == 0) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -2496,7 +2498,7 @@ static NTSTATUS lsa_lookup_name(struct lsa_policy_state *state, TALLOC_CTX *mem_ name = p + 1; } - ret = gendb_search(state->sam_ldb, mem_ctx, NULL, &res, attrs, "sAMAccountName=%s", name); + ret = gendb_search(state->sam_ldb, mem_ctx, NULL, &res, attrs, "sAMAccountName=%s", ldb_binary_encode_string(mem_ctx, name)); if (ret == 1) { *sid = samdb_result_dom_sid(mem_ctx, res[0], "objectSid"); if (*sid == NULL) { diff --git a/source4/rpc_server/samr/dcesrv_samr.c b/source4/rpc_server/samr/dcesrv_samr.c index e2b1a3bddc..3de85388dd 100644 --- a/source4/rpc_server/samr/dcesrv_samr.c +++ b/source4/rpc_server/samr/dcesrv_samr.c @@ -186,7 +186,7 @@ static NTSTATUS samr_LookupDomain(struct dcesrv_call_state *dce_call, TALLOC_CTX ret = gendb_search(c_state->sam_ctx, mem_ctx, NULL, &ref_msgs, ref_attrs, "(&(&(nETBIOSName=%s)(objectclass=crossRef))(ncName=*))", - r->in.domain_name->string); + ldb_binary_encode_string(mem_ctx, r->in.domain_name->string)); if (ret != 1) { return NT_STATUS_NO_SUCH_DOMAIN; } @@ -537,7 +537,7 @@ static NTSTATUS samr_CreateDomainGroup(struct dcesrv_call_state *dce_call, TALLO name = samdb_search_string(d_state->sam_ctx, mem_ctx, NULL, "sAMAccountName", "(&(sAMAccountName=%s)(objectclass=group))", - groupname); + ldb_binary_encode_string(mem_ctx, groupname)); if (name != NULL) { return NT_STATUS_GROUP_EXISTS; } @@ -741,7 +741,8 @@ static NTSTATUS samr_CreateUser2(struct dcesrv_call_state *dce_call, TALLOC_CTX /* check if the user already exists */ name = samdb_search_string(d_state->sam_ctx, mem_ctx, NULL, "sAMAccountName", - "(&(sAMAccountName=%s)(objectclass=user))", account_name); + "(&(sAMAccountName=%s)(objectclass=user))", + ldb_binary_encode_string(mem_ctx, account_name)); if (name != NULL) { return NT_STATUS_USER_EXISTS; } @@ -969,7 +970,7 @@ static NTSTATUS samr_CreateDomAlias(struct dcesrv_call_state *dce_call, TALLOC_C name = samdb_search_string(d_state->sam_ctx, mem_ctx, NULL, "sAMAccountName", "(sAMAccountName=%s)(objectclass=group))", - alias_name); + ldb_binary_encode_string(mem_ctx, alias_name)); if (name != NULL) { return NT_STATUS_ALIAS_EXISTS; @@ -1251,7 +1252,8 @@ static NTSTATUS samr_LookupNames(struct dcesrv_call_state *dce_call, TALLOC_CTX r->out.types.ids[i] = SID_NAME_UNKNOWN; count = gendb_search(d_state->sam_ctx, mem_ctx, d_state->domain_dn, &res, attrs, - "sAMAccountName=%s", r->in.names[i].string); + "sAMAccountName=%s", + ldb_binary_encode_string(mem_ctx, r->in.names[i].string)); if (count != 1) { status = STATUS_SOME_UNMAPPED; continue; |