You can't do what you've asked, but there are three alternatives I'll describe here
Include a syntactically valid
smb.confsnippet that defines your users.valid users = user1, user2, user3Include this snippet in your share definition. For example, if the snippet is called
/usr/local/etc/smb.valid_users.confyou would declare your share like this[example share] path = /example/path/here read only = no guest ok = no include = /usr/local/etc/smb.valid_users.confWhen you change the list of users you may need to restart samba (
systemctl restart smbd). Notice that because this is aninclude, any valid code can be added - including entire shares that give away far more access than you would expect. Do not allow untrusted users access to change the configuration file!Put the users into a group and reference the group in the share definition.
valid users = @usersgroupThen exactly as usual you create the group
usersgroup(seegroupaddoraddgroupdepending on your OS variant) and add your users to itTemplate the
smb.confand substitute into it as necessary. (The least favourite of my options.) Copysmb.conftosmb.conf.templateand use this line in your share definition,valid users = %USERSLIST%Then use something like
sedto substitute into the templatesed 's/%USERSLIST%/user1, user2, user3/g' /etc/samba/smb.conf.template >/etc/samba/smb.conf
linux - Link samba valid users to text file - Unix & Linux Stack Exchange
linux - How do I define a samba share so that every user can only see its own home? - Unix & Linux Stack Exchange
iOS Files App connects to Samba as Read-Only, but other apps work perfectly.
SMB share only works in read-only
Videos
Just add comma ',' if you want multiple valid users. See line that I used below.
valid users = @group1, @group2
I wound up adding the users from the most restricted group Directors to the Staff and Interns group as well as their original group. Then I added the users from the Staff group to the Interns group as well as their original group.
The line I used was a simple
valid users = @group_name