Why is Samba not adding a new user with "samba-tool"?

As far as I know the samba-tool is for Active Directory (AC) provisioning only. So if you haven't setup your Samba as AC server, samba-tool user add will not work.

You should ask yourself if you need an Active Directory Server in your Network or do you only need a simple Samba-Server only with it's own users.

I the case that you need an AC Server you should follow the guide which is provided by the samba project itself ( https://wiki.samba.org/index.php/Samba_AD_DC_HOWTO ). But be warned, this documentation does not suite to ubuntu directly and you need to understand the stuff that is depending on it (namely DNS, Kerberos, LDAP).

If you only need a simple server that has some Accounts for it's own purpose and provides access to some shared folders you should follow the guides for samba3. Samba4 is compatible with these setups to samba3 and though you need smbpasswd to create user in samba. The "General Samba Guides" of the Ubuntu Server Documentation should give you all the information you need.


Just write this instead in the terminal:

smbpasswd -a penguin

And the user you're adding needs to be added in the Ubuntu system, like a new user.

That can be done using

sudo useradd penguin

or

sudo adduser penguin

I'm concerned that this 'bug' may be miscategorized, because its showing up in so many different forms. I just found a bug-report going back to 2014, reporting exactly the same thing I encountered:

samba-tool user list ...fails repeatedly. But then, so do all the other commands involving samba-tool, except: samba-tool -V (which reports the version number correctly)

Here's the tip (or I should say 'a tip') of the iceberg:

acel:/mnt/nsd# samba-tool user list Unknown parameter encountered: "acl xattr update mtime" Ignoring unknown parameter "acl xattr update mtime" ERROR(ldb): uncaught exception - ldb_search: invalid basedn '(null)' File "/usr/lib/python2.7/dist-packages/samba/netcmd/init.py", line 175, in _run return self.run(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/samba/netcmd/user.py", line 292, in run attrs=["samaccountname"]) acel:/mnt/nsd# samba-tool user list ERROR(ldb): uncaught exception - ldb_search: invalid basedn '(null)'
File "/usr/lib/python2.7/dist-packages/samba/netcmd/init.py", line 175, in _run return self.run(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/samba/netcmd/user.py", line 292, in run attrs=["samaccountname"]) acel:/mnt/nsd# which ldb ldb: Command not found.

The problem? After encountering this on one system, I checked samba-tool on three other independent systems (all Ubuntu), and samba-tool was broken on them too. I've found a few isolated references to similar manifestations in bug reports, some going back 4-6 years. I've also found several reports of the bug having been 'fixed'...(this variation is not fixed).

All I wanted to do was make sure the samba user/password database was clean, by removing an orphan, and I couldn't. Clearly, if samba-tool isn't working (and in my case, I have 4 servers running Samba, and its not working on any of them) it needs to be fixed.

The only other clue I can offer: one reference I read mentioned the synchronization of passwords feature in Samba as a possible cause. I encountered this when samba encountered an orphan samba userid, which I had created by renaming its original twin in the /etc/passwd file. I was just trying to use samba-tool to remove the orphan. But I suppose its possible that when samba tried to synchronize its user database with the system, and found the original user missing, some damage was done.(?)

This isn't an answer. Its just a suggestion that the bug is probably still out there, and the best place to start checking to see if you're affected, is to run samba-tool simple functions, to see if its working properly:

'samba-tool user list' or 'samba-tool dbcheck' for example.

All of mine (1 V4.7 & 3 V4.3) are broken. (Hope this helps.)