int samdb_msg_add_parameters(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
			     const char *attr_name, struct lsa_BinaryString *parameters)
{
	int i;
	struct ldb_val val;
	if ((parameters->length % 2) != 0) {
		return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
	}

	val.data = talloc_array(mem_ctx, uint8_t, parameters->length);
	if (val.data == NULL) {
		return LDB_ERR_OPERATIONS_ERROR;
	}
	val.length = parameters->length;
	for (i = 0; i < parameters->length / 2; i++) {
		/*
		 * The on-disk format needs to be in the 'network'
		 * format, parmeters->array is a uint16_t array of
		 * length parameters->length / 2
		 */
		SSVAL(val.data, i * 2, parameters->array[i]);
	}
	return ldb_msg_add_steal_value(msg, attr_name, &val);
}
int samdb_msg_add_parameters(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
			     const char *attr_name, struct lsa_BinaryString *parameters)
{
	int i;
	struct ldb_val val;
	if ((parameters->length % 2) != 0) {
		return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
	}

	val.data = talloc_array(mem_ctx, uint8_t, parameters->length);
	if (val.data == NULL) {
		return LDB_ERR_OPERATIONS_ERROR;
	}
	val.length = parameters->length;
	for (i = 0; i < parameters->length / 2; i++) {
		 
		SSVAL(val.data, i * 2, parameters->array[i]);
	}
	return ldb_msg_add_steal_value(msg, attr_name, &val);
}