Ubuntu – Why is Samba not adding a new user with “samba-tool”


I'm trying to configure a Samba share on my Dell Poweredge 860 running server 14.04 LTS. Samba came uninstalled (when I chose it), so I just need to configure it. I'm trying to connect it to my Windows machine.

My config file (listed below) seems to be valid. I don't get any errors with it. It's a modified version of something I found on a tutorial online.

        workgroup = HOME
        server string = Samba Ubuntu Server
        map to guest = Bad User
        log file = /var/log/samba/log.%m
        max log size = 50
        socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
        local master = No
        dns proxy = No
        idmap config * : backend = tdb

        comment = "A small folder to move files from/to the server. For use by server admin."
        path = /serv/samba/queue
        valid users = penguin
        read only = No
        create mask = 0777
        directory mask = 0777

That's all fine there. (I should note that I have an account named penguin, too, but I want all the users to be configured using samba-tool because penguin is the only user account that will be on it, and there will be more users than there is now).

penguin@Ubuntu-Server-1:~/serv/samba$ sudo samba-tool user add penguin
New Password:
Retype Password:
ERROR(<type 'exceptions.ValueError'>): Failed to add user 'penguin':  - unable to parse dn string
  File "/usr/lib/python2.7/dist-packages/samba/netcmd/user.py", line 176, in run
    uid=uid, uidnumber=uid_number, gidnumber=gid_number, gecos=gecos, loginshell=login_shell)
  File "/usr/lib/python2.7/dist-packages/samba/samdb.py", line 343, in newuser
    dnsdomain = ldb.Dn(self, self.domain_dn()).canonical_str().replace("/", "")

I've tried it also with another username that's not on the system. It doesn't work.

I can't even accomplish a simple sudo samba-tool user list without errors!

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 271, in run

What am I doing wrong?

Best Answer

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.

Related Question