WERROR dns_get_zone_properties(struct ldb_context *samdb,
			       TALLOC_CTX *mem_ctx,
			       struct ldb_dn *zone_dn,
			       struct dnsserver_zoneinfo *zoneinfo)
{

	int ret, i;
	struct dnsp_DnsProperty *prop = NULL;
	struct ldb_message_element *element = NULL;
	const char *const attrs[] = {"dNSProperty", NULL};
	struct ldb_result *res = NULL;
	enum ndr_err_code err;

	ret = ldb_search(samdb,
			 mem_ctx,
			 &res,
			 zone_dn,
			 LDB_SCOPE_BASE,
			 attrs,
			 "(objectClass=dnsZone)");
	if (ret != LDB_SUCCESS) {
		DBG_ERR("dnsserver: Failed to find DNS zone: %s\n",
			ldb_dn_get_linearized(zone_dn));
		return DNS_ERR(SERVER_FAILURE);
	}

	element = ldb_msg_find_element(res->msgs[0], "dNSProperty");
	if (element == NULL) {
		return DNS_ERR(NOTZONE);
	}

	for (i = 0; i < element->num_values; i++) {
		bool valid_property;
		prop = talloc_zero(mem_ctx, struct dnsp_DnsProperty);
		if (prop == NULL) {
			return WERR_NOT_ENOUGH_MEMORY;
		}
		err = ndr_pull_struct_blob(
		    &(element->values[i]),
		    mem_ctx,
		    prop,
		    (ndr_pull_flags_fn_t)ndr_pull_dnsp_DnsProperty);
		if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
			/*
			 * If we can't pull it, then there is no valid
			 * data to load into the zone, so ignore this
			 * as Micosoft does.  Windows can load an
			 * invalid property with a zero length into
			 * the dnsProperty attribute.
			 */
			continue;
		}

		valid_property =
		    dns_zoneinfo_load_zone_property(zoneinfo, prop);
		if (!valid_property) {
			return DNS_ERR(SERVER_FAILURE);
		}
	}

	return WERR_OK;
}
WERROR dns_get_zone_properties(struct ldb_context *samdb,
			       TALLOC_CTX *mem_ctx,
			       struct ldb_dn *zone_dn,
			       struct dnsserver_zoneinfo *zoneinfo)
{

	int ret, i;
	struct dnsp_DnsProperty *prop = NULL;
	struct ldb_message_element *element = NULL;
	const char *const attrs[] = {"dNSProperty", NULL};
	struct ldb_result *res = NULL;
	enum ndr_err_code err;

	ret = ldb_search(samdb,
			 mem_ctx,
			 &res,
			 zone_dn,
			 LDB_SCOPE_BASE,
			 attrs,
			 "(objectClass=dnsZone)");
	if (ret != LDB_SUCCESS) {
		DBG_ERR("dnsserver: Failed to find DNS zone: %s\n",
			ldb_dn_get_linearized(zone_dn));
		return DNS_ERR(SERVER_FAILURE);
	}

	element = ldb_msg_find_element(res->msgs[0], "dNSProperty");
	if (element == NULL) {
		return DNS_ERR(NOTZONE);
	}

	for (i = 0; i < element->num_values; i++) {
		bool valid_property;
		prop = talloc_zero(mem_ctx, struct dnsp_DnsProperty);
		if (prop == NULL) {
			return WERR_NOT_ENOUGH_MEMORY;
		}
		err = ndr_pull_struct_blob(
		    &(element->values[i]),
		    mem_ctx,
		    prop,
		    (ndr_pull_flags_fn_t)ndr_pull_dnsp_DnsProperty);
		if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
			 
			continue;
		}

		valid_property =
		    dns_zoneinfo_load_zone_property(zoneinfo, prop);
		if (!valid_property) {
			return DNS_ERR(SERVER_FAILURE);
		}
	}

	return WERR_OK;
}