[PATCH] s4: Optimize ldb calls: replace two samdb_search_xxx by one gen_search_dn, reformat idl code
Matthieu Patou
mat at matws.net
Thu Sep 10 09:49:29 MDT 2009
---
librpc/idl/netlogon.idl | 2 +-
source4/rpc_server/netlogon/dcerpc_netlogon.c | 27 +++++++++++++------------
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/librpc/idl/netlogon.idl b/librpc/idl/netlogon.idl
index 34081e2..7ffc9f2 100644
--- a/librpc/idl/netlogon.idl
+++ b/librpc/idl/netlogon.idl
@@ -1372,7 +1372,7 @@ interface netlogon
uint32 dummy_long4;
} netr_OneDomainInfo;
- typedef [public,bitmap32bit] bitmap {
+ typedef [public,bitmap32bit] bitmap {
ENC_CRC32 = 0x00000001,
ENC_RSA_MD5 = 0x00000002,
ENC_RC4_HMAC_MD5 = 0x00000004,
diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c
index e349df0..dbbfb67 100644
--- a/source4/rpc_server/netlogon/dcerpc_netlogon.c
+++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c
@@ -1119,17 +1119,18 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_cal
TALLOC_CTX *mem_ctx, struct netr_LogonGetDomainInfo *r)
{
struct netlogon_creds_CredentialState *creds;
- const char * const attrs[] = { "objectSid", "objectGUID", "flatName",
+ const char * const attrs[] = { "dNSHostName","msDS-SupportedEncryptionTypes",NULL };
+ const char * const attrs2[] = { "objectSid", "objectGUID", "flatName",
"securityIdentifier", "trustPartner", NULL };
const char *temp_str;
const char *old_dns_hostname;
struct ldb_context *sam_ctx;
- struct ldb_message **res1, **res2, *new_msg;
+ struct ldb_message **res1, **res2, *new_msg, **res;
struct ldb_dn *workstation_dn;
struct netr_DomainInformation *domain_info;
struct netr_LsaPolicyInformation *lsa_policy_info;
struct netr_OsVersionInfoEx *os_version;
- int ret1, ret2, i;
+ int ret1, ret2, i, ret;
uint32_t client_supported_enc;
uint32_t default_supported_enc = ENC_CRC32|ENC_RSA_MD5|ENC_RC4_HMAC_MD5;
NTSTATUS status;
@@ -1171,16 +1172,16 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_cal
workstation_dn = ldb_dn_new_fmt(mem_ctx, sam_ctx, "<SID=%s>",
dom_sid_string(mem_ctx, creds->sid));
NT_STATUS_HAVE_NO_MEMORY(workstation_dn);
+ ret = gendb_search_dn(sam_ctx, mem_ctx,workstation_dn, &res, attrs);
+ if (ret != 1) {
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
/* Gets the old DNS hostname */
- old_dns_hostname = samdb_search_string(sam_ctx, mem_ctx,
- workstation_dn,
- "dNSHostName",
- NULL);
-
- client_supported_enc = samdb_search_int64(sam_ctx, mem_ctx, default_supported_enc,
- workstation_dn, "msDS-SupportedEncryptionTypes",
- NULL);
+ old_dns_hostname = ldb_msg_find_attr_as_string(res[0],"dNSHostName",NULL);
+ client_supported_enc = ldb_msg_find_attr_as_uint(res[0],
+ "msDS-SupportedEncryptionTypes",
+ default_supported_enc);
/* Gets host informations and put them in our directory */
new_msg = ldb_msg_new(mem_ctx);
NT_STATUS_HAVE_NO_MEMORY(new_msg);
@@ -1270,12 +1271,12 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_cal
put the primary domain into the lists of returned trusts as
well. */
ret1 = gendb_search_dn(sam_ctx, mem_ctx, samdb_base_dn(sam_ctx),
- &res1, attrs);
+ &res1, attrs2);
if (ret1 != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
- ret2 = gendb_search(sam_ctx, mem_ctx, NULL, &res2, attrs,
+ ret2 = gendb_search(sam_ctx, mem_ctx, NULL, &res2, attrs2,
"(objectClass=trustedDomain)");
if (ret2 == -1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
--
1.6.0.4
--------------040107040203010801000303--
More information about the samba-technical
mailing list