If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Samba 3.0: Using the ADS security mode

Active Directory support. Samba 3.0 is now able to
join a ADS(Active Directory Service) realm as a member
server and authenticate users using LDAP/Kerberos.

The intent of this article is to show you how to configure your Linux machine and Samba server to participate in a Windows 2000 Active Directory domain as a Member Server using Kerberos authentication. This involves using the security = ADS security mode in Samba.

Why would you want to do this? This eliminates the need to create separate Samba user accounts on your Linux server so your Windows users can access the Samba shares. Besides eliminating a lot of administrative overhead, without this, you would need to try to keep the password for the Samba user account synched with the password for the user in the AD domain. If you didn't and a Windows user changed his password, he would be prompted for a password every time he accessed a Samba share.

Probably the main advantage to the security = ADS security mode is if you are running a Win2k AD domain in native mode and your security policy prohibits the use of NT-compatible authentication protocols. All of your workstations would be Windows 2000 or XP Professional. In this case, Samba was not previously able to act as a Domain Member server in the domain.

If you want to be able to use winbind (discussed in another article), your Samba server MUST be a domain Member Server.

If you're not familiar with the different AD modes, here's a brief explanation. In mixed mode, all windows clients are able to authenticate to the domain including Win9x, NT4, Win2k, and XP Pro. Samba could also be a Member Server of this domain.
Active Directory in native mode perfectly allows NT4-style Domain Members. This is contrary to popular belief.

Active Directory in native mode prohibits only the use of Backup Domain Controllers running MS Windows NT4. Using AD in native mode and restricting the use of the NT-compatible authentication protocols (i.e., using Kerberos authentication), only Win2k and XP Pro clients can belong to the domain. If you have a network with just Win2k and XP Pro clients, this is the preferred and most secure mode.

The intended audience of this article are those who are already experienced with configuring Samba. It is assumed that the reader has sucessfully configured a Samba server in the past to integrate with a Windows domain or has a thorough understanding of how it is done. This would be using either the security = server or security = domain security modes. The reader would not need experience in configuring Samba to act as a Primary Domain Controller(PDC). This article is not intended for those who have never used Samba before. It should be obvious that having a working Windows 2000 AD domain is also a must.

The only version of Linux I've tried this on is Red Hat 9, so that's what this article is geared towards. It should work on any version of Linux though once you get Kerberos installed and working.

NETWORK SETUP

This is the setup on my network:

Linux:
Red Hat 9 with Samba 2.2.8a installed from the RPM package from Samba.org, not from the RH CDs.
host/NetBIOS name - delldim(10.10.1.151)
Samba server was set up using security = server and used the Win2k AD DC for authentication.

The most crucial thing you need to make this work is to have Kerberos V5 installed on your Linux machine. For Red Hat 9, the 2 rpm packages you need to have installed are krb5-libs and krb5-workstation. You should also install the krb5-server package so the documentation pages that are installed with this package are available. You will not need to configure your RH 9 machine as a Kerberos server, though.

You can check to see if they are already installed by using the rpm -q command:

rpm -q krb5-libs
rpm -q krb5-workstation
rpm -q krb5-server

These should return the version numbers, not error messages.

If you don't already have them installed, you can find them on the Red Hat 9 CD#2. You can install them from the command line using:

Once you get Kerberos installed on your Red Hat machine, there's a few critical things you need to check:

1. The time on your Win2k AD server and your Red Hat machine must match. The default Kerberos setting allows for a 5-minute discrepency. I reccomend setting them as close as possible to allow for drift over time. This is ABSOLUTELY CRITICAL! If the clocks don't match, it won't work.
This also applies to any other machine in your AD domain you want to authenticate to from your RH 9 machine using Kerberos.
2. Any user account in the Win2k AD domain you are going to use for authentication using Kerberos must have had the password changed at least once since it was created. If the password has never been changed since the account was created THIS WON'T WORK!!. On the accounts I used, I just changed the passwords, then changed them right back to their originals.

This is something that tripped me up until I found a small note about it in one of the HOWTOs. I had to change the password on both the administrator account and the user account I normally use so this would work.

INSTALLING SAMBA 3.0

Here's the steps to follow to install Samba 3.0:

1. Remove the old version of Samba from the computer with this command:

rpm -e samba

If you installed Samba from the RH CDs, you will probably have to remove more than one rpm package. You can use the RH 9 GUI package manager or execute:

rpm -qa | grep samba

to list the samba packages that are installed, then uninstall them from the command line.

You should uninstall your current version of Samba before installing Samba 3. When you remove Samba, the rpm command will back up your smb.conf file to smb.conf.rpmsave. I reccomend you make a back up copy of it yourself though.

If you're not using Red Hat 9, then use the method that is specific to your Linux distribution to uninstall Samba. If you installed Samba from source, see the documentation from Samba.org to uninstall it.

2. Download and install Samba 3 rpm package for RH9.
Once it's downloaded from the Samba.org site, just use:

rpm -ivh samba-3.0.0-1.i386.rpm

to install it.

If you're not using Red Hat 9, then use the method that is specific to your Linux distribution to install it. If you are installing Samba from source, see the documentation from Samba.org to install it.

Once you install it, make the smb.conf.rpmsave file your active smb.conf file or restore your backup copy of smb.conf, then start Samba. Test it to be sure it works as it did before. Your Samba server should work the same with Samba 3 as it did with Samba 2.2.

Once you've tested Samba 3 to be sure it's working properly, it's CRITICAL that you stop it before you continue with further configuration. If you don't stop Samba, the following attempts to configure it will most likely fail.

CONFIGURE KERBEROS

If you're not familiar with Kerberos, there's a few things you can read to familiarize yourself with it:

The most important thing in configuring Kerberos is the /etc/krb5.conf file. There should be an example one in /etc you can modify(that's what I did). If not, then just create one. Here's a copy of mine:

All of the literature I read said the realm name should be in upper case but doesn't have to be. I took their recommendation.

As you can see, I named my realm the same as the AD Domain name. It just so happens that my AD Domain name is the same as my network domain name but that's not always the case.

Use your AD DC as the kdc(Key Distribution Center) in your file. You should also list it as the admin server. If you have more than one DC in your AD domain, you can list them as kdc entries.

Once you get your krb5.conf file done, you can test it with the kinit command. Execute:

kinit username@REALM

where username is the name of an account in your AD Domain. It should prompt you for a password. Enter the password for that user in the AD Domain. Note that you must enter the name of the realm in uppercase letters.

If it executes without error, then execute klist to see your Kerberos ticket.
Here are the commands I entered:

When you install Samba from the Samba.org rpm package, it will also install SWAT. Before you configure Samba, I suggest you fire up SWAT and read the document listed on the SWAT home page titled "The Samba HOWTO Collection" It has a section in it that deals with Win2k AD and Kerberos.

You now need to make the changes to your smb.conf file to enable Kerberos authentication and so you can join the AD domain. The important lines in smb.conf are:

Once you make the changes to smb.conf and before you start Samba, you need to join the AD domain. Before you do so there are two things that you should check:

- If there is a file named /etc/samba/secrets.tdb either delete, move or rename it. This file would be from your previous connections to the domain. A new one will be created when you join the domain.
- If there is an existing machine account in your AD domain for your Samba server, delete it. A new one will be created when you join the AD domain.

The first command gets the Kerberos ticket you need to authenticate to the AD domain. You need to use the username of an account in your AD domain that has permission to join computers to the domain. The second command joins the domain.

If you're familiar with the command used with Samba 2.2 to join a domain, you'll notice the difference. smbpasswd is not used any more for this purpose.

If you successfully join the AD domain, you should receive a message stating that you successfully joined the Domain. You should also see a new /etc/samba/secrets.tdb file. There should also be a new machine account created in your Active Directory. If you look at the properties of the machine account, you should see that the OS is listed as Samba 3.0.

Once you've successfully joined the AD domain, start Samba in Red Hat using:

service smb start

or use whatever command you use with your distribution to start Samba.

TEST

You should now be able to access the shares on your Samba server from your Windows machines. In my case, I have XP Pro machines as clients. I can access the shares on my Red Hat 9, Samba 3 server without any problems. You can control access to the Linux file system or the Samba shares just as you did with Samba 2.2.

One advantage to using this type of authentication is that you don't need to create Samba accounts on the Linux server with the smbpasswd command. There is no need for the /etc/samba/smbpasswd file. You Windows users only need to be be concerned with one user account.

However, each user that accesses the Samba server will still need to have a valid Linux user account on the server that matches the account in the AD domain. The purpose of this account is to control access to the the Linux file system. The password for that account does not need to match the Win2k AD domain account password. The account doesn't even need to have the ability to log in locally to the Linux machine. It does have to exist however and it must have the proper permissions to the directories you are sharing out with Samba for the user to access them. This hasn't changed from Samba 2.2.

To get around the need for for local Linux accounts, you need to use winbind. It'll be interesting to see how that will work in conjuction with an AD domain. But that's the subject of another article.

If God hadn't meant for us to use GUI tools, there wouldn't have been a Xerox PARC.