This is what works for me in Ubuntu 18.04:
I added an fstab entry for the fileshare directory on the file server:
//server.my.domain.name/directory /mount/point cifs noauto,users,_netdev,sec=krb5
Then I created a shell script with the file extension .sh in /etc/profile.d to mount the directory on login, but only for users who belong to the appropriate domain:
if [[ " $(groups) " =~ ' domain [email protected] ' ]]; then mount /mount/point >/dev/null fi
The paths above have been anonymized to protect the guilty ;-}
P.S. If your network takes too long to start, you may need something that takes that into account, such as:
for i in {1..30} # give up if server isn't reachable in 30 seconds do sleep 1 # wait a second if [ ping -c1 server.my.domain.name &> /dev/null ]; then continue # loop if server can't be reached elif [[ " $(groups) " =~ ' domain [email protected] ' ]]; then mount /mount/point >/dev/null # mount share once server responds fi done
WARNING: This is untested; use at your own risk!