Authenticating Windows To OpenLDAP Server On Ubuntu 9
Authenticating Windows To OpenLDAP Server On Ubuntu 9
Authenticating Windows To OpenLDAP Server On Ubuntu 9
10
This is a quick guide to setting up LDAP on your server so that Linux/Windows users can
join your domain. This was written specifically because I saw several people complaining
that it could not be done on Ubuntu 9.10 and I figured, "Hey I've worked it out, so why not
share it?"
I have used the guide at least 4 times on a clean install of Ubuntu 9.10. It has worked
100% without so much as a hiccup. It should work for you too ;)
Edit: I forgot to mention, but this is based on this thread and is simply updated for 9.10 and
fixed up a little in a few random areas.
LDAP
At-a-Glance
1.Download necessary packages
2.Prepare the System
3.Configure slapd
4.Prepare LDAP for use with Samba
You can use Synaptic Package Manager if you want, just make sure the following four
packages are installed (make sure to accept any dependencies as well)
slapd
ldap-utils
db4.2-util
samba-doc
I chose to use the terminal window because Ive given you the entire command to just copy
and paste. Its a lot quicker than searching through Synaptic.
Rather than having LDAP store every user we create in the home directory, were going to
create a separate directory for LDAP to use. This is really more of a house keeping issue
than anything else. It make keeping track of things a little easier (in my opinion).
There is one important thing you should know before following this part of my guide. slapds
latest build allows you to dynamically make changes to the directory structure without
requiring a restart. This is a great feature but there is one small problem: It sucks. Ive
spent HOURS reading the official documentation trying to figure out how to use the stupid
thing and it still makes no sense. Its bulky, complicated, and requires way too much work
to make changes. It needs some serious revision (like an easy to use GUI) before I make
the transition (Or at least some better documentation, shesh).
However, using the old method is a temporary solution. Its a known fact that at some point
the people who release slapd will remove support for the older way of modifying slapd. So
you have two choices.
1.Follow this guide to replace the new method (slapd.d directory structure) with the original
method (slapd.conf file) and then be forced to upgrade at some point in the (distant, not so
distant?) future.
2.Use this guide as a basis for what to do, but learn how to use the new method yourself.
Okay, with that out of the way...
1.The first step is to completely remove the slapd.d directory. To do so open a terminal
window with root privileges and enter the following command.
rm -r /etc/ldap/slapd.d
SLAPD_CONF=
SLAPD_CONF=/etc/ldap/slapd.conf
Enter the following two commands in a terminal window with root privileges
gunzip /usr/share/doc/samba-doc/examples/LDAP/samba.schema.gz
cp -v /usr/share/doc/samba-doc/examples/LDAP/samba.schema /etc/ldap/schema
4.Decide on a LDAP administrator password and generate a SSHA hash key for it
slappasswd -s YOUR-PASSWORD-GOES-HERE
{SSHA}LQFFfwELK3few56afcsdaDSADS135w
5.Create an init.lidf file
In just a minute were going to use this file to populate our LDAP server. Enter the
command
gedit /etc/ldap/init.ldif
Since there is no file by that name yet, gedit will automatically create it for you. Copy and
paste the following into your empty init.ldif file. Remember to replace each dc=example,
dc=local with your own domain information. Look below the box for a description of the
main term in this file.
Code:
dn: dc=example,dc=local
objectClass: dcObject
objectClass: organizationalUnit
dc: example
ou: My Example File
Copy and paste the following then save and close it. Remember to replace example.local
with your actual domain information.
Code:
# Remember to replace suffix "dc=example,dc=local" with your domain name
# Change the rootpw entry with the results from slappaswd (Must match the
same you pasted on init.ldif)
# /etc/ldap/slapd.conf
# This is the main slapd configuration file. See slapd.conf(5) for more
# info on the configuration options.
########################################################################
#Global Directives:
# Features to permit
#allow bind_v2
# The tool-threads parameter sets the actual amount of cpu's that is used
# for indexing.
tool-threads 1
#######################################################################
# Specific Backend Directives for bdb:
# Backend specific directives apply to this backend until another
# 'backend' directive occurs
backend bdb
#checkpoint 512 30
#######################################################################
# Specific Backend Directives for 'other':
# Backend specific directives apply to this backend until another
# 'backend' directive occurs
#backend <other>
#######################################################################
# Specific Directives for database #1, of type bdb:
# Database specific directives apply to this databasse until another
# 'database' directive occurs
database bdb
# For the Debian package we use 2MB as default but be sure to update this
# value if you have plenty of RAM
dbconfig set_cachesize 0 2097152 0
# Sven Hartge reported that he had to set this value incredibly high
# to get slapd running at all. See http://bugs.debian.org/303057
# for more information.
# Save the time that the entry gets modified, for database #1
lastmod on
######################################################################
# Specific Directives for database #2, of type 'other' (can be bdb too):
# Database specific directives apply to this databasse until another
# 'database' directive occurs
#database <other>
/etc/init.d/slapd stop
rm -rf /var/lib/ldap/*
slapadd -v -l /etc/ldap/init.ldif
If all goes well you should see a final line that looks like this:
Make sure that LDAP has the correct privileges to access its own directory
/etc/init.d/slapd start
If its working then it should list all the entries that we created in the init.ldif file.
Samba
At-a-Glance
1.Install Samba
2.Configure Samba
3.Configure smbldap-tools
Install Samba
Again, we have two options of installing Samba. For those who want to use a bash prompt:
apt-get --yes install samba libpam-smbpass smbldap-tools
For the Synaptic fans make sure you install the following packages
samba (not samba 4! I've discovered at the time of this writing Samba 3.4 is
one of two versions (the other is 3.3.4) of samba that can allow Windows 7
machines to join the domain! samba 4 might work, but use it at your own risk!
So PLEASE use 3.4!)
libpam-smppass
smbldap-tools
mkdir -v /var/lib/samba/profiles
chmod 777 /var/lib/samba/profiles
mkdir -v -p /var/lib/samba/netlogon
gedit /etc/samba/smb.conf
Delete EVERYTHING that is there and replace it with the following. Be sure to replace
EXAMPLE with your information.
Code:
[global]
# Domain name ..
workgroup = EXAMPLE
# Server name - as seen by Windows PCs ..
netbios name = SERVERNAME
# Be a PDC ..
domain logons = Yes
domain master = Yes
# Be a WINS server ..
wins support = true
# 4 OUs that Samba uses when creating user accounts, computer accounts, etc.
# (Because we are using smbldap-tools, call them 'Users', 'Computers', etc.)
ldap machine suffix = ou=Computers
ldap user suffix = ou=Users
ldap group suffix = ou=Groups
ldap idmap suffix = ou=Idmap
# Samba and LDAP server are on the same server in this example.
ldap ssl = no
[Profiles]
comment = Roaming Profile Share
# would probably change this to elsewhere in a production system ..
path = /var/lib/samba/profiles
read only = No profile
acls = Yes
browsable = No
[printers]
comment = All Printers
path = /var/spool/samba
use client driver = Yes
create mask = 0600
guest ok = Yes
printable = Yes
browseable = No
public = yes
writable = yes
admin users = root
write list = root
[print$]
comment = Printer Drivers
Share path = /var/lib/samba/printers
write list = root
create mask = 0664
directory mask = 0775
admin users = root
smbpasswd -W
4.Restart Samba
/etc/init.d/samba restart
Configure smbldap-tools
cd /usr/share/doc/smbldap-tools/examples/
cp smbldap_bind.conf /etc/smbldap-tools/
cp smbldap.conf.gz /etc/smbldap-tools/
gzip -d /etc/smbldap-tools/smbldap.conf.gz
cd /etc/smbldap-tools/
net getlocalsid
gedit /etc/smbldap-tools/smbldap.conf
We need to make the following changes, but you cannot just copy and paste them into the
file. You need to search for them and make the adjustments.
Code:
SID="S-1-5-21-949328747-3404738746-3052206637" ## This line must have the
same SID as when you ran "net getlocalsid"
sambaDomain="EXAMPLE"
ldapTLS="0"
suffix="dc=example,dc=local"
sambaUnixIdPooldn="sambaDomainName=EXAMPLE,${suffix}" ## Be careful with
this section!!
userHome="/ldaphome/%U" ## This is found in the UNIX section.
userSmbHome=
userProfile=
userHomeDrive=
userScript=
mailDomain="example.local"
gedit /etc/smbldap-tools/smbldap_bind.conf
slaveDN="cn=admin,dc=example,dc=local"
slavePw="12345"
masterDN="cn=admin,dc=example,dc=local"
masterPw="12345"
smbldap-populate
At the very end it will ask you to enter a password for samba. Go ahead and enter the same
password you used when you used the command slappasswd s
7.Stop the LDAP server, run slapindex, and restart the LDAP server.
/etc/init.d/slapd stop
slapindex
chown openldap:openldap /var/lib/ldap/*
/etc/init.d/slapd start
Slapd should start with no problem. If it doesnt retrace your steps in the config files and
check for the following. Especially check smbladp_bind.conf and make sure you didnt
misspell your password. Otherwise check your smbldap.conf file and make sure you made
all the appropriate changes.
You shouldnt need to look anywhere else but those two files. The reason being that slapd
was already running successfully up to this point. Any reason for its failure should be
isolated to the changes you just made.
OpenLDAP
At-a-Glance
1.Add a User
2.Add LDAP authentication
3.Add a Windows computer to the domain
Add a User
Your directory is almost ready for use, but so far no one is in it! Lets add a user. Ill use the
example of matthew, but you might as well change it to be whatever user name you plan on
using yourself (well be giving it root privileges). I suggest on making the name different
from user name you set up during installation just to keep things clean.
Before were done setting up this user account, we need to add a password.
smbldap-passwd matthewb
Configure Authentication
gedit /etc/ldap.conf
Find the following referenced lines and make the changes indicated (Make sure to
uncomment them if they are commented out)
Code:
host 127.0.0.1
base dc=example,dc=loca
luri ldap://127.0.0.1/
rootbinddn cn=admin,dc=example,dc=local
bind_policy soft
cp /etc/ldap.conf /etc/ldap/ldap.conf
gedit /etc/auth-client-config/profile.d/open_ldap
Code:
[open_ldap]
nss_passwd=passwd: compat ldap
nss_group=group: compat ldap
nss_shadow=shadow: compat ldap
nss_netgroup=netgroup: nis
pam_auth=auth required pam_env.so
auth sufficient pam_unix.so likeauth
nullok
auth sufficient pam_ldap.so
use_first_pass
auth required pam_deny.so
pam_account=account sufficient pam_unix.so
account sufficient pam_ldap.so
account required pam_deny.so
pam_password=password sufficient pam_unix.so nullok md5
shadow use_authtok
password sufficient pam_ldap.so
use_first_pass
password required
pam_deny.so
pam_session=session required pam_limits.so
session required
pam_mkhomedir.so skel=/etc/skel/ umask=0077
session required pam_unix.so
session optional pam_ldap.so
auth-client-config -a -p open_ldap
gedit /etc/auth-client-config/profile.d/open_ldap
nss_netgroup=netgroup: nis
auth-client-config -a -p open_ldap
Command again, youll get server error messages about how a certain command already
exists. As long as you do not see
All that's left to do is to allow Samba services through your firewall (Ports 137-139 and 445).
This is necessary because we are using Samba as a stop-gap between LDAP and the
windows machines.
I really hope this guide helps you. Windows and openLDAP certainly aren't the easiest thing
to get to work together (A direct authentication via Kerberos would be awesome), but it
CAN be done! Good luck guys (and gals too I guess:P)!
While getting one of my machines to join the domain I learned two very nasty little tidbits.
The first is that Vista and 7 have about 3 too many versions (stupid Microsoft) and for some
reason only professional and up have the ability to actually join a domain. The second thing
I learned was that they both require some... convincing to join a Samba domain. I don't
have Vista so I couldn't test if the second part was needed or not, if you use vista please let
me know if it worked and if it didn't what did work for you in the end.
3. Go to:
Local Policies -> Security Options
4. Find the Policy named "Network Security: LAN Manager authentication level.
At this point, I am unaware of anything else Vista needs to get onto the domain. Windows
7, however needs some more work.
1. Samba 3.4 MUST be installed. I mentioned this earlier but there are some known issues
with samba and windows 7. Samba 3.4 does not have those problems (3.4 is, at the time of
this writing, the most recent version of the "samba" package)
Go to: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\servic
es\LanmanWorkstation\Parameters]
DomainCompatibilityMode (set to 1)
DNSNameResolutionRequired (set to 0)
RequireSignOrSeal
RequireStrongKey
Okay, Windows 7 should now join the domain! Good luck to all!