How to Build an Ubuntu 11.10 SBS (Small Business Server)

Part 8: Connecting Microsoft Windows Clients

To get this working we’re going to need to make some changes to the server, installing Samba to act as an Active Directory Primary Domain Controller… thankfully, that’s a lot easier than it sounds!

Server Configuration

sudo apt-get install samba libpam-smbpass

That will install Samba and import all of your user accounts for use with Samba. Furthermore, new user accounts will automatically be synchronised with their Samba counterparts.

Let’s create a Kerberos principal for the Samba service to use, ssh into the server and run the following:

sudo kadmin.local -q "addprinc -randkey cifs/"
sudo kadmin.local -q "addprinc -randkey cifs/neo"
sudo kadmin.local -q "ktadd -k /etc/krb5.keytab -e rc4-hmac:normal cifs/"
sudo kadmin.local -q "ktadd -k /etc/krb5.keytab -e rc4-hmac:normal cifs/neo"

Be sure to include the encryption type when running ktadd. The default encryption type is not compatible with the Samba client utilities. You’ll notice both the FQDN and the hostname of the server have been added. I hope to clean this up soon, but at the moment this is the only way I’ve managed to be sure it will work.

Now we need to configure Samba:

sudo nano /etc/samba/smb.conf

This file contains a comprehensive and well commented list of all of Samba’s configuration settings and is well worth reading through, the changes we’re particularly interested in are detailed below though:

workgroup =
security = user
kerberos method = system keytab
domain logons = yes
logon path = \\%N\%U\windowsprofile
logon drive = H:
logon home = \\%N\%U
logon script = logon.cmd
add machine script  = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u

Most of the above simply need a # or a ; deleting from the beginning of their line in the config file to enable them.

We also need to enable some shares in the configuration file, these are found towards the end of the file under the title “Share Definitions”

   comment = Home Directories
   browseable = no
   read only = no
   valid users = %S

   comment = Network Logon Service
   path = /home/samba/netlogon
   guest ok = yes
   read only = yes
   share modes = no

Now we need to create the netlogon folder and an empty netlogon.cmd (this will be used later to run commands each time a user logs on – perhaps to mount another share, etc.):

sudo mkdir -p /home/samba/netlogon
sudo touch /home/samba/netlogon/logon.cmd

Now we just need to restart Samba to make the changes take effect:

sudo service smbd restart
sudo service nmbd restart

we also need to create a group called “machines” for Samba to use when the add machine script is run. This will happen whenever you join a new Windows machine to your domain.

sudo ldapaddgroup machines

To be able to recognise your Unix admins as Windows admins we need to map the windows admin group to the unix admin group like so:

sudo net groupmap add ntgroup="Domain Admins" unixgroup=domainadmins rid=512 type=d

You also need to give admins who are allowed to add machines to the network explicit rights to do so. The following command gives the user dan the ability to use the add machine script and therefore join windows machines to the domain.

net rpc rights grant -U dan "\Domain Admins" SeMachineAccountPrivilege SePrintOperatorPrivilege SeAddUsersPrivilege SeDiskOperatorPrivilege SeRemoteShutdownPrivilege

If you get an authentication error here, check that you have added your realm information to /etc/krb5.conf on the server (in this case neo). See the Kerberos section of this guide for how to do that.

Connecting Windows 7 Clients

Windows 7 requires a registry change to be able to connect to a Samba domain. Download and run this registry entry on the client machine. Once added to the registry, restart the machine (or at least the lanman service).

Now would also be a good time to run the optimisations reg file. These tweaks are NOT necessary, but they do improve login speed.

Then go to Control Panel, System and Security, System and under “Computer name, domain and workgroup settings” click “Change settings”. Click the “Change” button on the dialogue that appears and enter “DANBISHOP.ORG” in the domain box. Click ok.

You will then be prompted for the domain administrators details to join the domain, in this case username dan and associated password. It will take sometime to connect to the domain, but eventually you will be shown a dialogue box welcoming you to the DANBISHOP.ORG domain. Restart the computer and you’ll be able to login as any of your domain users.

If you get a username/password not recognised error, log the user into a linux machine (or the server itself via ssh) and you should see “Added user .” printed to the terminal. The user can now use the Samba domain.

  • shane piper

    Hi Dan, I have been following your blog on setting up an SBS so far so good apart from when I get to the part for adding an ldap group.

    sudo ldapaddgroup domainadmins

    I get an error: Error adding group domainadmins to LDAP

    I have read in a previous blog about the ldap.secret password having to be 1 more than the password length but not having much joy.

    The ldapscripts log talks about the credentials not being correct (49).

    I have installed phpldapadmin as well to see if I can add the groups and users there but it doesn’t add a GID to the group.

    Any ideas?

  • shane piper

    I also added the ldap password to /etc/pam_ldap.secret and fixed the error I had above.



  • shane piper


    Sorry to be a pain, but now that I have set up the client machine when I go to login with an ldap user, I get the message ‘Could not update ICEauthority file /home/spiper/.ICEauthority’

    When I look at the home folder on the server there is no ICEauthority file.

  • jim smith

    Dan (or anyone reading this page) , if you could help me on this that would be great… i run the command

    “sudo ldapaddgroup domainadmins”

    i receive an output of “Could not guess current user”

    having a look round it seems the error is related to the $USER variable not being defined. But other than that i have no idea how to debug and fix this.

  • Myself

    I’ve installed LDAP and Kerberos, but how the two work together is a complete puzzle. Can you elaborate a bit on the roles of each one?

  • Daiko Dauda

    Hi Dan

    Thanks for an excellent set of steps described above.
    I do have on query…everything works no problems, but I struggle to add normal users and am I able to create eg – print admin, etc (other like groups) with specific permissions?

    Thanks again


    NB: can add-users but cannot generate passwords am I missing the point here?

    • Dan Bishop

      To generate passwords, you just create a new kerberos principal with the same name as the username… 🙂

  • Dan,

    This is a great idea, but rather than make the same mistake microsoft made with SBS, why not use Linux Containers or KVM and modularize the single physical box design so as to make the system more scalable and easier to migrate to new hardware?

    Even back in my Windows consulting days, I found that installing SBS on top of ESXi often saved clients money in the long term.


    • Dan Bishop

      Hi Sam,

      I am hoping to look at KVM when I get a bit more time. Maybe even making some preconfigured images with a script to modify the configuration for a custom domain… 🙂