Debian 11 comming with Samba 4.13 , but if wont to install latest version of Samba on fortunately, there is custom repository https://apt.van-belle.nl/ for Debian and Ubuntu.
Prepare :
sudo apt-get install wget apt-transport-https gnupg
Add apt.van-belle.nl repository :
wget -O- https://apt.van-belle.nl/louis-van-belle.gpg-key.asc | gpg --dearmor | sudo tee /usr/share/keyrings/louis-van-belle.gpg > /dev/null
echo "# AptVanBelle repo for samba." | sudo tee -a /etc/apt/sources.list.d/van-belle.list
echo "deb [signed-by=/usr/share/keyrings/louis-van-belle.gpg] http://apt.van-belle.nl/debian/ bullseye-samba415 main" | sudo tee -a /etc/apt/sources.list.d/van-belle.list
That is all, now can install latest Samba :
sudo apt update
sudo apt install samba
Please support L.P.H. van Belle with Donate because he's doing a great job with maintenance of repositry for Debian & Ubuntu.