double ldb_msg_find_attr_as_double(const struct ldb_message *msg,
				   const char *attr_name,
				   double default_value)
{
	const struct ldb_val *v = ldb_msg_find_ldb_val(msg, attr_name);
	char *buf;
	char *end = NULL;
	double ret;

	if (!v || !v->data) {
		return default_value;
	}
	buf = talloc_strndup(msg, (const char *)v->data, v->length);
	if (buf == NULL) {
		return default_value;
	}

	errno = 0;
	ret = strtod(buf, &end);
	talloc_free(buf);
	if (errno != 0) {
		return default_value;
	}
	if (end && end[0] != '\0') {
		return default_value;
	}
	return ret;
}
double ldb_msg_find_attr_as_double(const struct ldb_message *msg,
				   const char *attr_name,
				   double default_value)
{
	const struct ldb_val *v = ldb_msg_find_ldb_val(msg, attr_name);
	char *buf;
	char *end = NULL;
	double ret;

	if (!v || !v->data) {
		return default_value;
	}
	buf = talloc_strndup(msg, (const char *)v->data, v->length);
	if (buf == NULL) {
		return default_value;
	}

	errno = 0;
	ret = strtod(buf, &end);
	talloc_free(buf);
	if (errno != 0) {
		return default_value;
	}
	if (end && end[0] != '\0') {
		return default_value;
	}
	return ret;
}