svn commit: samba r16108 - in branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules: .

abartlet at samba.org abartlet at samba.org
Thu Jun 8 23:22:06 GMT 2006


Author: abartlet
Date: 2006-06-08 23:22:04 +0000 (Thu, 08 Jun 2006)
New Revision: 16108

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

Log:
Fixes from working with the partition module.

We were not using the correct baseDN for the templates search.  Using NULL is no longer valid (like against AD).

While chasing that down, return proper error codes, and use the
ldb_set_errstr() to get a good error string back up to the UI layer.

Andrew Bartlett

Modified:
   branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/samldb.c


Changeset:
Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/samldb.c
===================================================================
--- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/samldb.c	2006-06-08 21:53:47 UTC (rev 16107)
+++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/samldb.c	2006-06-08 23:22:04 UTC (rev 16108)
@@ -483,12 +483,14 @@
 	struct ldb_message *t;
 	int ret, i, j;
 	
+	struct ldb_dn *basedn = ldb_dn_string_compose(msg, samdb_base_dn(msg), "cn=Templates");
 
 	/* pull the template record */
-	ret = ldb_search(module->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res);
+	ret = ldb_search(module->ldb, basedn, LDB_SCOPE_SUBTREE, filter, NULL, &res);
 	if (ret != LDB_SUCCESS || res->count != 1) {
-		ldb_debug(module->ldb, LDB_DEBUG_WARNING, "samldb: ERROR: template '%s' matched too many records\n", filter);
-		return -1;
+		ldb_set_errstring(module->ldb, talloc_asprintf(module, "samldb_copy_template: ERROR: template '%s' matched %d records, expected 1\n", filter, 
+					  res->count));
+		return LDB_ERR_OPERATIONS_ERROR;
 	}
 	t = res->msgs[0];
 
@@ -515,16 +517,16 @@
 				if ( ! samldb_find_or_add_value(module, msg, el->name, 
 								(char *)el->values[j].data,
 								(char *)el->values[j].data)) {
-					ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Attribute adding failed...\n");
+					ldb_set_errstring(module->ldb, talloc_asprintf(module, "Adding objectClass %s failed.\n", el->values[j].data));
 					talloc_free(res);
-					return -1;
+					return LDB_ERR_OPERATIONS_ERROR;
 				}
 			} else {
 				if ( ! samldb_find_or_add_attribute(module, msg, el->name, 
 								    (char *)el->values[j].data)) {
-					ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Attribute adding failed...\n");
+					ldb_set_errstring(module->ldb, talloc_asprintf(module, "Adding attribute %s failed.\n", el->name));
 					talloc_free(res);
-					return -1;
+					return LDB_ERR_OPERATIONS_ERROR;
 				}
 			}
 		}
@@ -532,7 +534,7 @@
 
 	talloc_free(res);
 
-	return 0;
+	return LDB_SUCCESS;
 }
 
 static int samldb_fill_group_object(struct ldb_module *module, const struct ldb_message *msg,
@@ -557,7 +559,6 @@
 
 	ret = samldb_copy_template(module, msg2, "(&(CN=TemplateGroup)(objectclass=groupTemplate))");
 	if (ret != 0) {
-		ldb_debug(module->ldb, LDB_DEBUG_WARNING, "samldb_fill_group_object: Error copying template!\n");
 		talloc_free(mem_ctx);
 		return ret;
 	}
@@ -755,13 +756,17 @@
 			   ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
 	if (ret >= 1) {
 		const char *name = samdb_result_string(dom_msgs[0], "name", NULL);
-		ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, "Attempt to add foreign SID record with SID %s rejected, because this domian (%s) is already in the database", dom_sid_string(mem_ctx, sid), name)); 
+		ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, 
+							       "Attempt to add foreign SID record with SID %s rejected, because this domian (%s) is already in the database", 
+							       dom_sid_string(mem_ctx, sid), name)); 
 		/* We don't really like the idea of foreign sids that are not foreign */
 		return LDB_ERR_CONSTRAINT_VIOLATION;
 	} else if (ret == -1) {
-		ldb_debug(module->ldb, LDB_DEBUG_FATAL, "samldb_fill_foreignSecurityPrincipal_object: error searching for a domain with this sid: %s\n", dom_sid_string(mem_ctx, dom_sid));
+		ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, 
+							       "samldb_fill_foreignSecurityPrincipal_object: error searching for a domain with this sid: %s\n", 
+							       dom_sid_string(mem_ctx, dom_sid)));
 		talloc_free(dom_msgs);
-		return -1;
+		return LDB_ERR_OPERATIONS_ERROR;
 	}
 
 	/* This isn't an operation on a domain we know about, so just



More information about the samba-cvs mailing list