svn commit: samba r6766 - in branches/SAMBA_4_0/source: libcli/cldap torture/ldap

tridge at samba.org tridge at samba.org
Fri May 13 06:28:22 GMT 2005


Author: tridge
Date: 2005-05-13 06:28:22 +0000 (Fri, 13 May 2005)
New Revision: 6766

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=6766

Log:
some more cldap tests ...

my best guess now is that w2k3 converts the & in the cldap query to an |
for the ldap search. at least it behaves roughly like that.

Modified:
   branches/SAMBA_4_0/source/libcli/cldap/cldap.c
   branches/SAMBA_4_0/source/torture/ldap/cldap.c


Changeset:
Modified: branches/SAMBA_4_0/source/libcli/cldap/cldap.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/cldap/cldap.c	2005-05-13 06:10:10 UTC (rev 6765)
+++ branches/SAMBA_4_0/source/libcli/cldap/cldap.c	2005-05-13 06:28:22 UTC (rev 6766)
@@ -502,23 +502,32 @@
 	const char *attr[] = { "NetLogon", NULL };
 	TALLOC_CTX *tmp_ctx = talloc_new(cldap);
 
-	filter = talloc_asprintf(tmp_ctx, 
-				 "(&(DnsDomain=%s)(Host=%s)(NtVer=%s)", 
-				 io->in.realm, io->in.host, 
+	filter = talloc_asprintf(tmp_ctx, "(&(NtVer=%s)", 
 				 ldap_encode_ndr_uint32(tmp_ctx, io->in.version));
 	if (filter == NULL) goto failed;
 	if (io->in.user) {
 		filter = talloc_asprintf_append(filter, "(User=%s)", io->in.user);
+		if (filter == NULL) goto failed;
 	}
+	if (io->in.host) {
+		filter = talloc_asprintf_append(filter, "(Host=%s)", io->in.host);
+		if (filter == NULL) goto failed;
+	}
+	if (io->in.realm) {
+		filter = talloc_asprintf_append(filter, "(DnsDomain=%s)", io->in.realm);
+		if (filter == NULL) goto failed;
+	}
 	if (io->in.acct_control != -1) {
 		filter = talloc_asprintf_append(filter, "(AAC=%s)", 
 						ldap_encode_ndr_uint32(tmp_ctx, io->in.acct_control));
+		if (filter == NULL) goto failed;
 	}
 	if (io->in.domain_sid) {
 		struct dom_sid *sid = dom_sid_parse_talloc(tmp_ctx, io->in.domain_sid);
 		if (sid == NULL) goto failed;
 		filter = talloc_asprintf_append(filter, "(domainSid=%s)",
 						ldap_encode_ndr_dom_sid(tmp_ctx, sid));
+		if (filter == NULL) goto failed;
 	}
 	if (io->in.domain_guid) {
 		struct GUID guid;
@@ -527,6 +536,7 @@
 		if (!NT_STATUS_IS_OK(status)) goto failed;
 		filter = talloc_asprintf_append(filter, "(DomainGuid=%s)",
 						ldap_encode_ndr_GUID(tmp_ctx, &guid));
+		if (filter == NULL) goto failed;
 	}
 	filter = talloc_asprintf_append(filter, ")");
 	if (filter == NULL) goto failed;

Modified: branches/SAMBA_4_0/source/torture/ldap/cldap.c
===================================================================
--- branches/SAMBA_4_0/source/torture/ldap/cldap.c	2005-05-13 06:10:10 UTC (rev 6765)
+++ branches/SAMBA_4_0/source/torture/ldap/cldap.c	2005-05-13 06:28:22 UTC (rev 6766)
@@ -80,6 +80,7 @@
 	CHECK_STATUS(status, NT_STATUS_OK);
 
 	printf("Trying with a GUID\n");
+	search.in.realm       = NULL;
 	search.in.domain_guid = GUID_string(mem_ctx, &n1.logon4.domain_uuid);
 	status = cldap_netlogon(cldap, mem_ctx, &search);
 	CHECK_STATUS(status, NT_STATUS_OK);
@@ -89,11 +90,17 @@
 	search.in.user        = NULL;
 	search.in.domain_guid = GUID_string(mem_ctx, &guid);
 	status = cldap_netlogon(cldap, mem_ctx, &search);
+	CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
+
+	printf("Trying with a incorrect domain and correct guid\n");
+	search.in.realm       = "test.example.com";
+	search.in.domain_guid = GUID_string(mem_ctx, &n1.logon4.domain_uuid);
+	status = cldap_netlogon(cldap, mem_ctx, &search);
 	CHECK_STATUS(status, NT_STATUS_OK);
 
-	printf("Trying with a incorrect domain\n");
+	printf("Trying with a incorrect domain and incorrect guid\n");
 	search.in.realm       = "test.example.com";
-	search.in.domain_guid = NULL;
+	search.in.domain_guid = GUID_string(mem_ctx, &guid);
 	status = cldap_netlogon(cldap, mem_ctx, &search);
 	CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
 
@@ -109,6 +116,20 @@
 	status = cldap_netlogon(cldap, mem_ctx, &search);
 	CHECK_STATUS(status, NT_STATUS_OK);
 
+	printf("Trying with a user only\n");
+	search.in.acct_control = -1;
+	search.in.user = "Administrator";
+	search.in.realm = NULL;
+	search.in.domain_guid = NULL;
+	status = cldap_netlogon(cldap, mem_ctx, &search);
+	CHECK_STATUS(status, NT_STATUS_OK);
+
+	printf("Trying without any attributes\n");
+	search.in.user = NULL;
+	search.in.host = NULL;
+	status = cldap_netlogon(cldap, mem_ctx, &search);
+	CHECK_STATUS(status, NT_STATUS_OK);
+
 done:
 	return ret;	
 }



More information about the samba-cvs mailing list