XBMC/Kodi and SMB access denied
Oh no, access denied
So I was trying Kodi on a new Android device I got (WeTek Play) and soon ran into a problem where I couldn't access my password protected SMB shares on my linux server where my media is stored. Kodi would just ask for the username and password over and over but never authenticate. The error in Kodi's log was:
SMBDirectory->GetDirectory: Unable to open directory : 'smb://USERNAME:PASSWORD@server' unix_err:'d'error : 'Permission denied'
Now the thing was I've been using these shares from XBMC/Kodi on windows for many years and I could access these shares fine from every other machine and device... in fact even from this very same android device, just not from Kodi.
So after googling for a while without any result except people suggesting to just allow guest access to the shares (omg!?). I vaguely remembered that the linux builds, and so probably android, generate a client smb configuration file. In this file lanman auth is enabled in order to be compatible with older servers. The problem is lanman is disabled by default in any "recent" samba version (as in since Samba 3.6.0 from 2011) and I wouldn't want to recommend enabling this broken and deprecated authentication method.
What you want to do in this case is enable de default NTLMv2 authentication.
To do this you have to edit the smb.conf file stored on the device in
(path will vary with device) and add
client NTLMv2 auth = yes
on a new line. You can use ES File Explorer for instance to edit the file. Save, and start Kodi.
If you can't find the file then just enable debug logging in system settings from within Kodi and it will show the path on screen where the logfile is stored which is close to where smb.conf is stored on your device.