Active Directory Integration

From ArchWiki
Revision as of 20:50, 5 February 2012 by Sharkoslinux (Talk | contribs) (Major rewrite of the article to fix some workflow issues, and improve the quality of the article.)

Jump to: navigation, search

This guide explains how to include ArchLinux into an existing Windows Active Directory.


A key challenge for system administrators of any datacenter is trying to coexisting in Heterogeneous environments. By this we mean the mixing of different server operating system technologies (typicall Microsoft Windows & Unix/Linux). User management and authentication is by far the most difficult of these to solve. The most common way of solving this problem is to use a Directory Server. There are a number of open-source and commercial solutions for the various flavors of *NIX; however, few solve the problem of interoperating with Windows. Active Directory (AD) is a directory service created by Microsoft for Windows domain networks. It is included in most Windows Server operating systems. Server computers on which Active Directory is running are called domain controllers.

Active Directory serves as a central location for network administration and security. It is responsible for authenticating and authorizing all users and computers within a network of Windows domain type, assigning and enforcing security policies for all computers in a network and installing or updating software on network computers. For example, when a user logs into a computer that is part of a Windows domain, it is Active Directory that verifies his or her password and specifies whether he or she is a system administrator or normal user.[1]

Active Directory uses Lightweight Directory Access Protocol (LDAP) versions 2 and 3, Kerberos and DNS. These same standards are available as linux, but piecing them together is not an easy task. Following these steps will help you configure an ArchLinux host to authenticate against an AD domain.


Before starting, you must have an existing Active Directory domain, and have the appropriate rights within the domain to query users, and add computer accounts (Domain Join).

The following packages should also be installed:

  • samba
  • krb-5
  • pam-krb5
  • pam_pwcheck
  • openntpd (or) ntp
pacman -S samba pam-krb5 pam_pwcheck openntpd

Preparation of the Windows AD policy

    • NOTE: This step has not been validated
It is necessary to disable Digital Sign Communication (Always) in the AD group policies. Dive into:

Local policies -> Security policies -> Microsoft Network Server -> Digital sign communication (Always) -> activate "define this policy" and use the disable radio button

If you use Windows Server 2008 R2, you need to modify that in GPO for Default Domain Controller Policy -> Computer Setting -> Policies -> Windows Setting -> Security Setting -> Local Policies -> Security Option -> Microsoft network client: Digitally sign communications (always)

This is all you have to do in Windows. Let's go on with Arch Linux.


Please check your /etc/hosts file! It is important for it to be correctly configured. If you have a dual boot system on a machine, you have to use a different hostname and netbios name for the linux configuration, or the protected connection between windows and the domain controller will result broken.


Samba / Winbindd startup

Arch Linux implements samba and winbind as a single script in /etc/rc.d/samba

The daemons started by /etc/rc.d/samba are configured in the file /etc/conf.d/samba.

##### /etc/conf.d/samba #####
#SAMBA_DAEMONS=(smbd nmbd)
SAMBA_DAEMONS=(smbd nmbd winbindd)

Heimdal / Kerberos - /etc/krb5.conf

Let's assume that your AD is named Let's further assume your AD is ruled by two domain controllers, the primary and secondary one, which are named adam and eve, and respectively. Their IP adresses will be and in this example. Take care to watch your syntax; upper-case is very important here.

##### /etc/krb5.conf ####
        default_realm 	= 	PARADISE.COM
	clockskew 	= 	300
	ticket_lifetime	=	1d
		kdc 	=
		kdc 	=
		default_domain = PARADISE.COM
[domain_realm] 	= 	PARADISE.COM	= 	PARADISE.COM
	paradise	= 	PARADISE.COM

	pam = {
	ticket_lifetime 	= 1d
	renew_lifetime 		= 1d
	forwardable 		= true
	proxiable 		= false
	retain_after_close 	= false
	minimum_uid 		= 0
	debug 			= false

	kdc 			= FILE:/var/log/kdc.log 


Heimdal 1.3.1 deprecated DES encryption which is required for AD authentication before Windows Server 2008. You'll probably have to add
allow_weak_crypto = true
to the [libdefaults] section.

Inside an AD, it is important that all machines run the same system time. To synchronize the time run:


Now you can query the AD domain controllers for a ticket with the following commands (uppercase is necessary):


You´ll now be asked for the password. In case it matches, you'll be returned to the console.

PAM configuration for login

Now we have to change /etc/pam.d/login so it sends its request to the AD controllers. In case of logins, PAM should first ask for AD accounts, and for local accounts if no matching AD account was found. Therefore, we add entries to include into the authentication process. Furthermore, we include If an AD user logs in, /home/paradise/user will be created automatically.

#### /etc/pam.d/login ####
auth     sufficient
auth     required use_first_pass use_authtok
auth     required
auth     required
auth     required
account  sufficient
account  sufficient use_first_pass use_authtok
password required
password sufficient
password sufficient use_first_pass use_authtok
session  required skel=/etc/skel/ umask=0022
session  sufficient
session  sufficient use_first_pass use_authtok
session  required

If you like to allow AD users to login into GDM, you have to do the same for /etc/pam.d/gdm. You may try to change other /etc/pam.d/ rules for other apps, to allow them to authenticate AD users.

Samba configuration for shares

Samba is highly configurable. Take this example only as a rough idea, hardly polished. Here is what my /etc/samba/smb.conf looks like:

#### /etc/samba/smb.conf ####
netbios name = archlinux
workgroup = PARADISE
server string = archlinux
map to guest = Bad User
idmap uid = 10000-20000
idmap gid = 10000-20000
winbind enum users = yes
winbind enum groups = yes
winbind gid = 10000-20000
winbind use default domain = Yes
winbind separator =+
os level = 20

# Theres no shell defined for users in AD, so I define a default shell to use
# Not sure if its even possible to define a shell in AD
template shell = /bin/bash
encrypt passwords = yes
security = ads
password server =
preferred master = no
dns proxy = no
wins server =
wins proxy = no

admin users = @"NET+domain admins"
force group = "PARADISE+domain admins"
inherit acls = Yes
map acl inherit = Yes
acl group control = yes

load printers = no
debug level = 3
use sendfile = no
comment = User´s homedirs
path =/home/%U
valid users = %S NET+%S
browseable = no
read only = no

comment = Data
valid users = %S net+%S
path = /data
read only = no
browseable = yes
comment = Backup filer
path = /backup
read only = no
browseable = yes
valid users = @"NET+Domain Admins"

We shall now explain to Samba that it shall use the PDC´s database for authentication queries. Again, we use winbindd which is a part of the samba package. Winbind maps the UID and GID of the AD to our Linux-machine. Winbind uses a Unix-implementation of RPC-calls, Pluggable Authentication Modules (aka PAM) and Name Service Switch (NSS) to allow Windows AD and users accessing and to grant permissions on the Linux-machine. The best part of winbindd is, that you don´t have to define the mapping yourself, but only define a range of UID and GID. That´s what we defined in smb.conf. To include Winbindd into NSS calls, edit /etc/nsswitch.conf. Add winbind to the lines as shown here:

#### /etc/nsswitch.conf ####
passwd:            files winbind
shadow:            files winbind
group:             files winbind

Starting and testing services

Starting Samba

Hopefully, you have not rebooted yet! Fine. If you are in an X-session, quit it, so you can test login into another console, while you are still logged in.

Start Samba (including smbd, nmbd and winbindd:

/etc/rc.d/samba restart

Testing Winbind

Let's check if winbind is able to query the AD. The following command should return a list of AD users:

wbinfo -u

We can do the same for AD groups:

wbinfo -g

Testing login

Now, start a new console session and try to login with an AD account. As we told winbind to use default_realms, it should not be necessary to add the AD name. Lets assume there is an AD user named kain. Try to login as


Both should work. You should notice that /home/paradise/kain will be created. Log into another session using an linux account. Check that you still be able to log in as root - but keep in mind to be logged in as root in at least one session!

Testing Samba commands

Try out some net commands to see if samba can address the AD:

net ads info
net ads lookup
net ads status

The commands return several AD related information.

Arch Linux becomes an AD member

You need an AD Administrator account to do this. Let's assume this is named Administrator. The command is 'net ads join'

# net ads join -U Administrator
Administrator's password: xxx
Using short domain name -- PARADISE

When to reboot?

Everything checked? OK. Pray and reboot.


Everything there is to know about Samba

Please feel free to comment this article - but if your edit this - PLEASE LET ME KNOW