How to implement Samba as your PDC (Primary Domain Controller) for your domain
23 December 2004
Version 1.0
Disclaimer: This HOWTO has no guarantee. Use at your own risk. Back up any relevant data before proceding. If you break your system, it's up to you to fix it. Don't blame me (or the Gentoo forums) as I/we bear no responsibility if you are inept with simple procedures. Please read through this HOWTO prior to any attempt at installing your Samba PDC.
Resources:
O'Reilly - Using Samba -- This is a slightly outdated book but it's help is priceless.
samba.org -- Excellent resource for parameter definitions. Not a good resource to learn samba with.
Gentoo Forums Thread #1
Gentoo Forums Thread #2
Synopsis
This HOWTO was created because all of the resources that I encountered were either outdated or simply incorrect. This is my step by step outline that I used to successfully implement a Samba server as my PDC on my local network. This should work for anyone that attempts this implementation.
This HOWTO describes how to implement samba as your PDC so that a) users on your domain authenticate against a central domain controller and b) selected network drives are mapped on login. In addition, this will also explain how to implement a roaming profile. This HOWTO is practical only for domains which employ Windows 2000 professional workstations. I have not attempted nor tested against any other version of Windows. However, I know it can be done, just do some research.
What this HOWTO will do
- Allow Windows 2000 clients to authenticate via your samba server
- Provide mapped drives (based on logon scripts)
- Execute a logon script
- Enable use of roaming profiles
What this HOWTO will not do
- Allow Windows 9x/XP clients to authenticate via your samba server
- Configure your Samba server for print sharing
If you wish to implement print sharing, follow this HOWTO and add only relevant printer information. Don't forget to add cups support when compiling samba.
Step by Step
- Configure USE variable in /etc/make.conf
- Install Samba (version 3.0.9 (portage version 3.0.9-r1) as of this writing)
- Configure Samba
- Configure Win2k workstations
- More Samba configuration
- Final steps
These are the flags I've configured on my machine. Make sure that you enable pam (or kerberos/ldap depending on what auth method you wish to employ) and python, the rest are optional, depending on your needs. Enable cups for samba printer sharing.
Code: Select all
-acl -cups -debug -doc -kerberos -ldap* -libclamav -mysql -oav +pam -postgres +python -quotas +readline (-selinux) +winbind +xml +xml2Install Samba
Probably the easiest step. It is good practice to always do a pretend/verbose before installing any package. This way you know what is going to be installed (focusing on dependancies, if any). Kick back for a while as it takes about 15-30 minutes to install Samba, depending on hardware/optimizations. It'll take longer if any dependancies need to be installed.
Code: Select all
emerge sync
emerge samba -pv
emerge sambaNow we venture into configuring samba. For some, this is easy, for others, it's a pain in the arse as it was for me but at least I learned.
The first file we need to edit is /etc/samba/smb.conf. So fire that up with your favorite text editor. The first section we will configure is the [global] services section, followed by [netlogon], [profiles], [homes] and other services sections. Please note that parameter values reflect my network. You'll need to change some values to meet your criteria.
The [global] service section
netbios name sets the NetBIOS name by which a Samba server is known. This is what you'll see in network neighborhood. workgroup controls what workgroup your server will appear to be in when queried by clients. server string controls what string will show up in the printer comment box in print manager and next to the IPC connection in net view.
Code: Select all
netbios name = shadow (choose your own name)
workgroup = YOUR_DOMAIN
server string = PDC [on Gentoo :: Samba server %v]Code: Select all
hosts allow = 192.168.4.0/24 127.0.0.0/8
security = user
encrypt passwords = yes
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
interfaces = lo eth0
bind interfaces only = yesCode: Select all
local master = yes
os level = 65
domain master = yes
preferred master = yesCode: Select all
null passwords = no
hide unreadable = yes
hide dot files = yesFor logon script, I personally use a static file name. Using %U will require a batch file for each user as %U == the username establishing the connection.
Code: Select all
domain logons = yes
logon script = login.bat OR %U.bat
logon path = \\%L\profiles\%U
logon drive = H:
logon home = \\%L\%U\.9xprofileCode: Select all
wins support = yes
name resolve order = wins lmhosts hosts bcast
dns proxy = noCode: Select all
time server = yes
log file = /var/log/samba3/log.%m
max log size = 50
# location to samba password file
smb passwd file = /etc/samba/private/smbpasswdCode: Select all
add user script = /usr/sbin/useradd -m %u
delete user script = /usr/sbin/userdel -r %u
add group script = /usr/sbin/groupadd %g
delete group script = /usr/sbin/groupdel %g
add user to group script = /usr/sbin/usermod -G %g %u
add machine script = /usr/sbin/useradd -s /bin/false -d /dev/null %u
passwd program = /usr/bin/passwd %u
passwd chat = "*New password:*" %n\r "*New password (again):*" %n\r \ "*Password changed*"Code: Select all
unix charset = ISO8859-1This section defines your shares. If you include a parameter within any one of these sections that is defined in the global section it will override the parameter in the global section. I'm not going to get into detail about each and every parameter here. The samba link provided above is a great resource for defining parameters. Use it!
netlogon is the service section of where your Default Profile (for new users) and your login script reside. Make sure the directory is owned and group owned by root and permissions are 755 (chmod -R 0755).
Code: Select all
[netlogon]
path = /var/lib/samba/netlogon
public = no
writeable = no
browseable = noCode: Select all
[profiles]
path = /var/lib/samba/profiles
browseable = no
writeable = yes
default case = lower
preserve case = no
short preserve case = no
case sensitive = no
hide files = /desktop.ini/ntuser.ini/NTUSER.*/
write list = @smbusers @root
create mode = 0600
directory mode = 0700Code: Select all
[homes]
path = /home/%U
browseable = no
valid users = %S
writable = yes
guest ok = no
inherit permissions = yesCode: Select all
[public]
comment = Public Stuff
path = /public
public = yes
writeable = no
browseable = yes
write list = @users
The drawback to using samba is that users have to be added twice. Once to your /etc/passwd and once to /etc/samba/private/smbpasswd. I'm going to assume you already have a regular daily user so I'm going to skip the "adduser" unix command. Obviously, and hopefully, root exists on your system. =)
Both of the following commands will prompt you for a password. My suggestion is keep your [Samba] root password that same as your [Unix] system root password. Applying the same to your user password. Keep things simple.
Code: Select all
smbpasswd -a your_user
smbpasswd -a rootThis is another simple step. Log into your Windows 2000 client locally as Administrator and add your client machine to your domain. This is achieved by right clicking My Computer => Properties => Network Identification => Properties button. You will be prompted for a username/password of an authorised domain user. You'll need to use your root account (the reason root was added to smbpasswd).
After changing your domain, you'll need to reboot (no surprise there). When it reboots, you'll have the fancy login screen with the nice little graphic instructing you to do a "ctrl-alt-del" to get to the actual login screen. If you only see fields for you username and password, click on the "Options" button and a domain dropdown will appear. Your choices should be "computer name\local" AND your new domain.
In order to employ roaming profiles, you need to establish a "Default Profile" on Samba. This requires you to copy the content of C:\Documents and Settings\Default Profile to your samba server. You will need to copy it into the directory specified in your [netlogon] service. This way your users will have a default profile to log into (assuming the usage of roaming profiles).
I suggest making sure the latest service pack is installed.
After adding the client to the domain and rebooting, lets leave this screen as is. We'll come back to it later.
More Samba Configuration
We're almost there.
This step maps your Windows groups to your Unix groups. This is an important step if you want admin rights on your Windows clients once you have logged onto the client authorizing against the PDC.
First, view the list of Windows groups. This way you know what you're mapping.
Code: Select all
root@shadow profiles # net groupmap list
System Operators (S-1-5-32-549) -> -1
Replicators (S-1-5-32-552) -> -1
Guests (S-1-5-32-546) -> -1
Domain Guests (S-1-5-21-3885047494-3765334852-1543503842-514) -> nobody
Domain Admins (S-1-5-21-3885047494-3765334852-1543503842-512) -> ntadmins
Power Users (S-1-5-32-547) -> -1
Print Operators (S-1-5-32-550) -> -1
Administrators (S-1-5-32-544) -> 1
Account Operators (S-1-5-32-548) -> -1
Domain Users (S-1-5-21-3885047494-3765334852-1543503842-513) -> users
Backup Operators (S-1-5-32-551) -> -1
Users (S-1-5-32-545) -> -1Code: Select all
root@shadow profiles # groupadd ntadminsCode: Select all
root@shadow profiles # net groupmap modify ntgroup="Domain Admins" unixgroup=ntadminsFinal steps
Now that we are done with configuring Samba, let's start it and add it to your default run levels (or whatever run level you choose)
Code: Select all
root@shadow profiles # /etc/init.d/samba start
root@shadow profiles # rc-update add samba defaultFin! Have a Godless day!
Addition notes
There are a few things I'm unsure of.
- Can Samba be configured to automatically enforce roaming profiles or does this have to be done per client?
- Even with the add user script parameter, how are users added from a Windows client?
Code: Select all
echo Setting Current Time...
net time \\shadow /set /yes
echo Mapping Network Drives to Domain network server...
net use H: /HOME
net use X: \\shadow\public
net use Y: \\shadow\audio
net use Z: \\shadow\videoKnown Issues
It's been confirmed that wallpapers don't follow with roaming profiles. The wallpaper does load if already cached on the local computer. I'm not sure where the problem exists.
Change log
1.4 - Found some typos, fixed.
1.3 - Moved HOWTO to gentoo-wiki.com. This thread will no longer be updated.
1.2 - Updated note on USE flags
1.1 - Added known issues
1.0 - HOWTO created






