Ever tried to integrate a Samba fileserver into an Active Directory domain?
Sorting out access permissions can be a nightmare, especially if you've got to
create local users in order to restrict access. The good news is that you don't
need to anymore. Providing you're using up to date versions (I'll post exactly
which later - I've always updated as necessary without noting the version numbers
too closely, but RedHat 9 comes with everything you need.) all you need to do
is use WinBind. This marvellous little daemon will acccess your Active Directory
and pull out the list of users and groups.
create or edit /etc/pam_smb.conf
(where [DOMAIN] is you Active Directory Domain and [DC1] and [DC2} are 2 domain
controllers.)
# pam_smb.conf
[DOMAIN]
[DC1]
[DC2}
# /etc/nsswitch.conf
#
#passwd: db files nisplus nis
#shadow: db files nisplus nis
#group: db files nisplus nis
passwd: files winbind db nisplus
shadow: files winbind db nisplus
group: files winbind db nisplus
#%PAM-1.0
auth required /lib/security/pam_winbind.so
auth required /lib/security/pam_stack.so service=system-auth
account required /lib/security/pam_winbind.so
account required /lib/security/pam_stack.so service=system-auth
password required /lib/security/pam_winbind.so
#%PAM-1.0
auth required /lib/security/pam_securetty.so
auth sufficient /lib/security/pam_winbind.so
auth sufficient /lib/security/pam_unix.so use_first_pass
auth required /lib/security/pam_stack.so service=system-auth
auth required /lib/security/pam_nologin.so
account sufficient /lib/security/pam_winbind.so
account required /lib/security/pam_stack.so service=system-auth
password required /lib/security/pam_stack.so service=system-auth
session required /lib/security/pam_stack.so service=system-auth
session optional /lib/security/pam_console.so
#%PAM-1.0
#auth required /lib/security/pam_stack.so service=system-auth
auth sufficient /lib/security/pam_winbind.so
auth sufficient /lib/security/pam_unix.so use_first_pass
auth required /lib/security/pam_stack.so service=system-auth
auth required /lib/security/pam_nologin.so
account sufficient /lib/security/pam_winbind.so
account required /lib/security/pam_stack.so service=system-auth
password required /lib/security/pam_stack.so service=system-auth
session required /lib/security/pam_stack.so service=system-auth
session required /lib/security/pam_limits.so
session optional /lib/security/pam_console.so
## Winbind
##
# specify the uid range which can be used by winbindd
# to allocate uids for Windows users as necessary
winbind uid = 10000-65000
# specify the uid range which can be used by winbindd
# to allocate uids for Windows users as necessary
winbind gid = 10000-65000
# Define a home directory to be given to passwd(5) style entries
# generated by libnss_winbind.so. You can use variables here
template homedir = /home/%D/%U
# Specify a shell for all winbind user entries return by the
# libnss_winbind.so library.
template shell = /bin/bash
# What character should be used to separate the DOMAIN and Username
# for a Windows user. The default is DOMAIN\user, but many people
# prefer DOMAIN+user
winbind separator = +
winbind enum users = yes
winbind enum groups = yes
[Files]
available = yes
browseable = yes
path = /home/samba/files
public = yes
writable = yes
valid users = nobody DOMAIN+User1 DOMAIN+User2 DOMAIN+User3 localuser
create mask = 764
inherit permissions = yes
[Websites]
available = yes
browseable = yes
path = /home/samba/websites
public = yes
writable = yes
valid users = nobody DOMAIN+User1 DOMAIN+User2 DOMAIN+User3 DOMAIN+User4 localuser
force user = nobody
force group = nobody
create mask = 755
inherit permissions = yes
The two shares shown are available to the specified Domain users (include the
DOMAIN and + separator with the username) together with a local user on the samba
server. Only the users explicitly listed can access the files since a Windows
2000 machine will not try and connect as nobody to access files in the shares.
smbpasswd -j DOMAIN -r DC1 -U Administrator
The proper response to the command should be: "Joined the domain DOMAIN"
where DOMAIN is your DOMAIN name.
Start the winbindd daemon and try wbinfo -u to verify it's working