The problem is that user_list is accessed as an array
for a in "${user_list[@]}"
but set as a string:
user_list="$(samba-tool user list | grep -i ${txt} | sort)"
Instead you need
IFS=$'\n' # split on newline characters
set -o noglob # disable globbing
# assign the users to the array using the split+glob operator
# (implicitly invoked in bash when you leave a command substitution
# unquoted in list context):
user_list=( $(samba-tool user list | grep -ie "${txt}" | sort) )
Or better (though bash-specific):
readarray -t user_list < <(samba-tool user list)
(note that that one would create one empty element for each empty line of the input if any, contrary to the split+glob approach which would discard empty lines).