unsigned int ldb_msg_find_attr_as_uint(const struct ldb_message *msg,
				       const char *attr_name,
				       unsigned int default_value)
{
	const struct ldb_val *v = ldb_msg_find_ldb_val(msg, attr_name);
	char buf[sizeof("-2147483648")];
	char *end = NULL;
	unsigned int ret;

	if (!v || !v->data) {
		return default_value;
	}

	ZERO_STRUCT(buf);
	if (v->length >= sizeof(buf)) {
		return default_value;
	}

	memcpy(buf, v->data, v->length);
	errno = 0;
	ret = (unsigned int) strtoll(buf, &end, 10);
	if (errno != 0) {
		errno = 0;
		ret = (unsigned int) strtoull(buf, &end, 10);
		if (errno != 0) {
			return default_value;
		}
	}
	if (end && end[0] != '\0') {
		return default_value;
	}
	return ret;
}
unsigned int ldb_msg_find_attr_as_uint(const struct ldb_message *msg,
				       const char *attr_name,
				       unsigned int default_value)
{
	const struct ldb_val *v = ldb_msg_find_ldb_val(msg, attr_name);
	char buf[sizeof("-2147483648")];
	char *end = NULL;
	unsigned int ret;

	if (!v || !v->data) {
		return default_value;
	}

	ZERO_STRUCT(buf);
	if (v->length >= sizeof(buf)) {
		return default_value;
	}

	memcpy(buf, v->data, v->length);
	errno = 0;
	ret = (unsigned int) strtoll(buf, &end, 10);
	if (errno != 0) {
		errno = 0;
		ret = (unsigned int) strtoull(buf, &end, 10);
		if (errno != 0) {
			return default_value;
		}
	}
	if (end && end[0] != '\0') {
		return default_value;
	}
	return ret;
}