static int samdb_find_or_add_attribute_ex(struct ldb_context *ldb,
					  struct ldb_message *msg,
					  const char *name,
					  const char *set_value,
					  unsigned attr_flags,
					  bool *added)
{
	int ret;
	struct ldb_message_element *el;

	SMB_ASSERT(attr_flags != 0);

       	el = ldb_msg_find_element(msg, name);
	if (el) {
		if (added != NULL) {
			*added = false;
		}

		return LDB_SUCCESS;
	}

	ret = ldb_msg_add_empty(msg, name,
				attr_flags,
				&el);
	if (ret != LDB_SUCCESS) {
		return ret;
	}

	if (set_value != NULL) {
		ret = ldb_msg_add_string(msg, name, set_value);
		if (ret != LDB_SUCCESS) {
			return ret;
		}
	}

	if (added != NULL) {
		*added = true;
	}
	return LDB_SUCCESS;
}
static int samdb_find_or_add_attribute_ex(struct ldb_context *ldb,
					  struct ldb_message *msg,
					  const char *name,
					  const char *set_value,
					  unsigned attr_flags,
					  bool *added)
{
	int ret;
	struct ldb_message_element *el;

	SMB_ASSERT(attr_flags != 0);

       	el = ldb_msg_find_element(msg, name);
	if (el) {
		if (added != NULL) {
			*added = false;
		}

		return LDB_SUCCESS;
	}

	ret = ldb_msg_add_empty(msg, name,
				attr_flags,
				&el);
	if (ret != LDB_SUCCESS) {
		return ret;
	}

	if (set_value != NULL) {
		ret = ldb_msg_add_string(msg, name, set_value);
		if (ret != LDB_SUCCESS) {
			return ret;
		}
	}

	if (added != NULL) {
		*added = true;
	}
	return LDB_SUCCESS;
}