版本:
[root@station19 ~]# uname -a
Linux station19.example.com 2.6.18-308.el5xen #1 SMP Fri Jan 27 17:59:00 EST 2012 i686 i686 i386 GNU/Linux
[root@station19 ~]# lsb_release -a
LSB Version: :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 5.8 (Tikanga)
Release: 5.8
Codename: Tikanga
[root@station19 ~]#
ldap.conf配置(红色粗体表示ldap.conf原本没有需要特别注意的):
* Windows 2008上需要把Linux-NSS用户加到Administrators组,这样Linux-NSS才有加AD的权限。
[root@station19 ~]# egrep -v "^#|^$" /etc/ldap.conf
host w2k8.ad.example.com
base dc=ad,dc=example,dc=com
binddn cn=Linux-NSS,cn=Users,dc=ad,dc=example,dc=com
bindpw p3ngu!n
timelimit 120
bind_timelimit 120
idle_timelimit 3600
nss_initgroups_ignoreusers root,ldap,named,avahi,haldaemon,dbus,radvd,tomcat,radiusd,news,mailman,nscd,gdm
nss_map_objectclass posixAccount user
nss_map_objectclass shadowAccount user
nss_map_objectclass posixGroup group
nss_map_attribute uid sAMAccountName
nss_map_attribute homeDirectory unixHomeDirectory
nss_map_attribute gecos cn
pam_login_attribute sAMAccountName
pam_filter objectclass=User
pam_password ad
nss_base_passwd cn=Users,dc=ad,dc=example,dc=com
ssl no
[root@station19 ~]#
[root@station19 ~]# authconfig-tui
[/usr/bin/net join -w AD -S w2k8.ad.example.com -U Linux-NSS]
Linux-NSS's password:<...>
Using short domain name -- AD
DNS update failed!
Joined 'STATION19' to realm 'AD.EXAMPLE.COM'
Shutting down Winbind services: [ OK ]
Starting Winbind services: [ OK ]
[root@station19 ~]# getent passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/etc/news:
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
nscd:x:28:28:NSCD Daemon:/:/sbin/nologin
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
pcap:x:77:77::/var/arpwatch:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
avahi:x:70:70:Avahi daemon:/:/sbin/nologin
rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin
mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin
smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
oprofile:x:16:16:Special user account to be used by OProfile:/home/oprofile:/sbin/nologin
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
avahi-autoipd:x:100:156:avahi-autoipd:/var/lib/avahi-autoipd:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
xfs:x:43:43:X Font Server:/etc/X11/fs:/sbin/nologin
gdm:x:42:42::/var/gdm:/sbin/nologin
student:x:500:500::/home/student:/bin/bash
visitor:x:501:501::/home/visitor:/bin/bash
[root@station19 ~]# wbinfo -u
AD\administrator
AD\guest
AD\krbtgt
AD\linux-nss
AD\gates
AD\user2008
[root@station19 ~]# net ads testjoin
Join is OK
[root@station19 ~]# net ads info
LDAP server: 192.168.0.250
LDAP server name: w2k8.ad.example.com
Realm: AD.EXAMPLE.COM
Bind Path: dc=AD,dc=EXAMPLE,dc=COM
LDAP port: 389
Server time: Tue, 30 Jul 2013 00:08:49 CST
KDC server: 192.168.0.250
Server time offset: 0
[root@station19 ~]#
smb.conf配置(红色部分为authconfig-tui之后要修改或增加的内容):
* winbind use default domain = true 表示去掉windows AD里面的域名,即把AD\gates变成gates
* 只有加了 winbind enum users = yes 和 winbind enum groups = yes 之后,才能通过getent passwd列出windows AD中的用户
[root@station19 ~]# egrep -v "^#|^$|^;|[[:space:]]+#" /etc/samba/smb.conf
[global]
workgroup = AD
password server = w2k8.ad.example.com
realm = AD.EXAMPLE.COM
security = ads
idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
template shell = /bin/bash
winbind use default domain = true
winbind enum users = yes
winbind enum groups = yes
winbind offline logon = false
server string = Samba Server Version %v
passdb backend = tdbsam
load printers = yes
cups options = raw
[homes]
comment = Home Directories
browseable = no
writable = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
[root@station19 ~]#
修改完smb.conf后重启winbind服务,getent passwd即可列出windows AD中的用户了
[root@station19 ~]# /etc/init.d/winbind restart
Shutting down Winbind services: [ OK ]
Starting Winbind services: [ OK ]
[root@station19 ~]# wbinfo -u
administrator
guest
krbtgt
linux-nss
gates
user2008
[root@station19 ~]# getent passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/etc/news:
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
nscd:x:28:28:NSCD Daemon:/:/sbin/nologin
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
pcap:x:77:77::/var/arpwatch:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
avahi:x:70:70:Avahi daemon:/:/sbin/nologin
rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin
mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin
smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
oprofile:x:16:16:Special user account to be used by OProfile:/home/oprofile:/sbin/nologin
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
avahi-autoipd:x:100:156:avahi-autoipd:/var/lib/avahi-autoipd:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
xfs:x:43:43:X Font Server:/etc/X11/fs:/sbin/nologin
gdm:x:42:42::/var/gdm:/sbin/nologin
student:x:500:500::/home/student:/bin/bash
visitor:x:501:501::/home/visitor:/bin/bash
administrator:*:16777217:16777216:Administrator:/home/AD/administrator:/bin/bash
guest:*:16777218:16777217:Guest:/home/AD/guest:/bin/bash
krbtgt:*:16777219:16777216:krbtgt:/home/AD/krbtgt:/bin/bash
linux-nss:*:16777220:16777216:Linux-NSS:/home/AD/linux-nss:/bin/bash
gates:*:16777216:16777216:Bill Gates:/home/AD/gates:/bin/bash
user2008:*:16777221:16777216:User2008:/home/AD/user2008:/bin/bash
[root@station19 ~]#
补充,上文中在加入AD域时碰到“DNS update failed!”的错误,这是因为默认Linux客户端没有和Windows AD服务器在同一个域里面。可通过在Linux客户端的/etc/hosts里面加条和Windows AD服务器在同一个域(ad.example.com)的主机名解决:
[root@station19 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.0.19 station19.ad.example.com station19.example.com station19
[root@station19 ~]# authconfig-tui
[/usr/bin/net join -w AD -S w2k8.ad.example.com -U Linux-NSS]
Linux-NSS's password:<...>
Using short domain name -- AD
Joined 'STATION19' to realm 'AD.EXAMPLE.COM'
Shutting down Winbind services: [ OK ]
Starting Winbind services: [ OK ]
[root@station19 ~]#
REF:
1. Windows AD和ldap结合出问题
http://phorum.study-area.org/index.php?topic=65043.0