svn commit: samba r23937 - in branches: SAMBA_3_2/source/libads SAMBA_3_2_0/source/libads

gd at samba.org gd at samba.org
Tue Jul 17 20:28:32 GMT 2007


Author: gd
Date: 2007-07-17 20:28:31 +0000 (Tue, 17 Jul 2007)
New Revision: 23937

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

Log:
Use ads_config_path() when we need to know the configration context.

Guenther

Modified:
   branches/SAMBA_3_2/source/libads/ldap.c
   branches/SAMBA_3_2_0/source/libads/ldap.c


Changeset:
Modified: branches/SAMBA_3_2/source/libads/ldap.c
===================================================================
--- branches/SAMBA_3_2/source/libads/ldap.c	2007-07-17 20:05:15 UTC (rev 23936)
+++ branches/SAMBA_3_2/source/libads/ldap.c	2007-07-17 20:28:31 UTC (rev 23937)
@@ -2662,8 +2662,8 @@
 {
 	ADS_STATUS status;
 	LDAPMessage *res;
-	const char *parent, *config_context, *filter;
-	const char *attrs[] = { "configurationNamingContext", NULL };
+	const char *parent, *filter;
+	char *config_context = NULL;
 	char *dn;
 
 	/* shortcut a query */
@@ -2671,26 +2671,18 @@
 		return ads_site_dn(ads, mem_ctx, site_dn);
 	}
 
-	status = ads_do_search(ads, "", LDAP_SCOPE_BASE, "(objectclass=*)", attrs, &res);
+	status = ads_config_path(ads, mem_ctx, &config_context);
 	if (!ADS_ERR_OK(status)) {
 		return status;
 	}
 
-	config_context = ads_pull_string(ads, mem_ctx, res, "configurationNamingContext");
-	if (config_context == NULL) {
-		ads_msgfree(ads, res);
-		return ADS_ERROR(LDAP_NO_MEMORY);
-	}
-
 	filter = talloc_asprintf(mem_ctx, "(cn=%s)", computer_name);
 	if (filter == NULL) {
-		ads_msgfree(ads, res);
 		return ADS_ERROR(LDAP_NO_MEMORY);
 	}
 
-	ads_msgfree(ads, res);
-
-	status = ads_do_search(ads, config_context, LDAP_SCOPE_SUBTREE, filter, NULL, &res);
+	status = ads_do_search(ads, config_context, LDAP_SCOPE_SUBTREE, 
+			       filter, NULL, &res);
 	if (!ADS_ERR_OK(status)) {
 		return status;
 	}
@@ -2739,34 +2731,27 @@
 {
 	ADS_STATUS status;
 	LDAPMessage *res;
-	const char *config_context, *base;
-	const char *attrs[] = { "configurationNamingContext", NULL };
-	const char *attrs2[] = { "uPNSuffixes", NULL };
+	const char *base;
+	char *config_context = NULL;
+	const char *attrs[] = { "uPNSuffixes", NULL };
 
-	status = ads_do_search(ads, "", LDAP_SCOPE_BASE, "(objectclass=*)", attrs, &res);
+	status = ads_config_path(ads, mem_ctx, &config_context);
 	if (!ADS_ERR_OK(status)) {
 		return status;
 	}
 
-	config_context = ads_pull_string(ads, mem_ctx, res, "configurationNamingContext");
-	if (config_context == NULL) {
-		ads_msgfree(ads, res);
-		return ADS_ERROR(LDAP_NO_MEMORY);
-	}
-
-	ads_msgfree(ads, res);
-
 	base = talloc_asprintf(mem_ctx, "cn=Partitions,%s", config_context);
 	if (base == NULL) {
 		return ADS_ERROR(LDAP_NO_MEMORY);
 	}
 
-	status = ads_search_dn(ads, &res, base, attrs2); 
+	status = ads_search_dn(ads, &res, base, attrs);
 	if (!ADS_ERR_OK(status)) {
 		return status;
 	}
 
 	if (ads_count_replies(ads, res) != 1) {
+		ads_msgfree(ads, res);
 		return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
 	}
 

Modified: branches/SAMBA_3_2_0/source/libads/ldap.c
===================================================================
--- branches/SAMBA_3_2_0/source/libads/ldap.c	2007-07-17 20:05:15 UTC (rev 23936)
+++ branches/SAMBA_3_2_0/source/libads/ldap.c	2007-07-17 20:28:31 UTC (rev 23937)
@@ -2662,8 +2662,8 @@
 {
 	ADS_STATUS status;
 	LDAPMessage *res;
-	const char *parent, *config_context, *filter;
-	const char *attrs[] = { "configurationNamingContext", NULL };
+	const char *parent, *filter;
+	char *config_context = NULL;
 	char *dn;
 
 	/* shortcut a query */
@@ -2671,26 +2671,18 @@
 		return ads_site_dn(ads, mem_ctx, site_dn);
 	}
 
-	status = ads_do_search(ads, "", LDAP_SCOPE_BASE, "(objectclass=*)", attrs, &res);
+	status = ads_config_path(ads, mem_ctx, &config_context);
 	if (!ADS_ERR_OK(status)) {
 		return status;
 	}
 
-	config_context = ads_pull_string(ads, mem_ctx, res, "configurationNamingContext");
-	if (config_context == NULL) {
-		ads_msgfree(ads, res);
-		return ADS_ERROR(LDAP_NO_MEMORY);
-	}
-
 	filter = talloc_asprintf(mem_ctx, "(cn=%s)", computer_name);
 	if (filter == NULL) {
-		ads_msgfree(ads, res);
 		return ADS_ERROR(LDAP_NO_MEMORY);
 	}
 
-	ads_msgfree(ads, res);
-
-	status = ads_do_search(ads, config_context, LDAP_SCOPE_SUBTREE, filter, NULL, &res);
+	status = ads_do_search(ads, config_context, LDAP_SCOPE_SUBTREE, 
+			       filter, NULL, &res);
 	if (!ADS_ERR_OK(status)) {
 		return status;
 	}
@@ -2739,34 +2731,27 @@
 {
 	ADS_STATUS status;
 	LDAPMessage *res;
-	const char *config_context, *base;
-	const char *attrs[] = { "configurationNamingContext", NULL };
-	const char *attrs2[] = { "uPNSuffixes", NULL };
+	const char *base;
+	char *config_context = NULL;
+	const char *attrs[] = { "uPNSuffixes", NULL };
 
-	status = ads_do_search(ads, "", LDAP_SCOPE_BASE, "(objectclass=*)", attrs, &res);
+	status = ads_config_path(ads, mem_ctx, &config_context);
 	if (!ADS_ERR_OK(status)) {
 		return status;
 	}
 
-	config_context = ads_pull_string(ads, mem_ctx, res, "configurationNamingContext");
-	if (config_context == NULL) {
-		ads_msgfree(ads, res);
-		return ADS_ERROR(LDAP_NO_MEMORY);
-	}
-
-	ads_msgfree(ads, res);
-
 	base = talloc_asprintf(mem_ctx, "cn=Partitions,%s", config_context);
 	if (base == NULL) {
 		return ADS_ERROR(LDAP_NO_MEMORY);
 	}
 
-	status = ads_search_dn(ads, &res, base, attrs2); 
+	status = ads_search_dn(ads, &res, base, attrs);
 	if (!ADS_ERR_OK(status)) {
 		return status;
 	}
 
 	if (ads_count_replies(ads, res) != 1) {
+		ads_msgfree(ads, res);
 		return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
 	}
 



More information about the samba-cvs mailing list