samba和openldap結合實戰(轉)

cjlozbgao發表於2014-12-24
samba和openldap結合實戰(轉)[@more@]

RedHat Enterprise Linux Server 4.2 + OpenLDAP + LDAP Browser/Editor + Samba + Squid + Postfix + Antivir-Mailgate + EGroupWare

作者:Fandy

電子郵箱:cbbc@163.com、cbbc@avl.com.cn

QQ號碼:332018422

建立日期:2006年01月16日,最後修改日期:2006年03月02日

版權說明:本文章的內容歸作者版權所有,同時也接受大家的轉貼,但一定要儲存作者資訊和出處,多謝!

因為軟體版權和費用的問題,一值是公司凝難問題(我們是一家中小型企業,沒有那麼多錢來投資和購買軟體license費用)。經過公司高層領導的決定,公司準備將所有Microsoft伺服器作業系統更改為RedHat Enterprise Server 4.2伺服器作業系統!公司高層領導對新網路改造要求也不高就是可以共享上網和印表機、公司郵件和使用者資料統一管理。

在網路配置過程中遇到了許多不明白的問題,好在有google.com這個好朋友和得到“日京三子、Extmail、fjufirefox”等幾位Linux前輩的指導,才可以順利完成這一次網路改造任務,真的要好多謝幾位前輩的幫助,多謝!

文章分為五大部分介紹實施情況:

第一部分:OpenLDAP主機安裝RedHat Enterprise Linux Server 4.2系統過程;

第二部分:DNS + OpenLDAP + Samba(PDC)+ LDAP Browser/Editor系統安裝和配置;

第三部分:Squid系統安裝和配置;

第四部分:Postfix + Dovecot + Antivir-Mailgate + MailScanner + EGroupWare系統安裝和配置;

第五部分:客戶端Windows XP、Fedora加入Samba PDC和電子郵件正常收發,EGroupWare的使用介紹;

Setp0、實現網路圖:

Setp1、OpenLDAP主機安裝RedHat Enterprise Linux Server 4.2作業系統截圖:

磁碟配置:

裝置 型別 大小

/ ext3 39911

swap 1024

網路基本配置:

etho IP/Gateway:192.168.1.254/255.255.255.0

主機名:ldap.easy.com

閘道器:192.168.1.1

主/次DNS:192.168.1.254/202.96.128.68

防火牆基本配置:

⊙ 無防火牆

⊙ 是否啟用 SELinux:已禁用

安裝方式的選項:

⊙ 定製要安裝的軟體包(C)

桌面選項:

(√) X視窗系統 (選取全部)

(√) GNOME桌面環境 (選取全部)

應用程式選項:

(√) 工程和科學 (選取預設)

(√) 圖形化網際網路 (選取預設)

(√) 基於文字的網際網路 (選取預設)

(√) 辦公/生產率 (選取預設)

伺服器選項:

(√) 伺服器配置工具 (選取全部)

(√) 全球資訊網伺服器 (選取全部)

(√) Windows檔案伺服器 (選取全部)

(√) DNS伺服器 (選取全部)

開發選項:

(√) 開發工具 (選擇全部)

系統選項:

(√) 管理工具 (選取預設)

(√) 列印支援 (選取預設)

雜項選項:

全部不要選擇;

OpenLDAP + Samba所需要的全部軟體包清單(包括:DNS、DB、OpenLDAP、Samba、Other):

bind-9.2.4-2.i386.rpm bind-chroot-9.2.4-2.i386.rpm

bind-devel-9.2.4-2.i386.rpm bind-libs-9.2.4-2.i386.rpm

bind-utils-9.2.4-2.i386.rpm

db4-4.2.52-7.1.i386.rpm db4-utils-4.2.52-7.1.i386.rpm

db4-devel-4.2.52-7.1.i386.rpm

openldap-2.2.13-3.i386.rpm openldap-clients-2.2.13-3.i386.rpm

openldap-devel-2.2.13-3.i386.rpm openldap-servers-2.2.13-3.i386.rpm

samba-3.0.10-1.4E.2.i386.rpm samba-client-3.0.10-1.4E.2.i386.rpm

samba-common-3.0.10-1.4E.2.i386.rpm samba-swat-3.0.10-1.4E.2.i386.rpm

smbldap-tools-0.9.1-1.2.el4.rf.noarch.rpm

perl-Crypt-SmbHash-0.02-1.2.el4.rf.noarch.rpm perl-Digest-SHA1-2.07-5.i386.rpm

perl-LDAP-0.31-5.noarch.rpm perl-XML-SAX-0.12-7.noarch.rpm

mod_authz_ldap-0.26-2.i386.rpm nss_ldap-226-6.i386.rpm

Setp2、DNS詳細配置過程:

修改/var/named/chroot/etc/named.conf檔案,新增以下內容如下:

詳細內容:

zone "easy.com" { #正解

type master;

file "/var/named/easy.com.hosts";

};

zone "1.168.192.in-addr.arpa" { #反解

type master;

file "/var/named/192.168.1.rev";

};

在/var/named/chroot/var/named/目錄建立正解easy.com.hosts檔案,檔案完整內容如下:

詳細內容:

$ttl 38400

easy.com. IN SOA ldap.easy.com. fandy.easy.com. (

1137063120

10800

3600

604800

38400 )

easy.com. IN NS ldap.easy.com.

easy.com. IN A 192.168.1.254

ldap.easy.com IN A 192.168.1.254

mail.easy.com. IN A 192.168.1.253

mail.easy.com. IN MX 10 mail.easy.com

在/var/named/chroot/var/named/目錄建立正解192.168.1.rev檔案,檔案完整內容如下::

詳細內容:

$ttl 38400

1.168.192.in-addr.arpa. IN SOA mail.easy.com. fandy.easy.com. (

1137063268

10800

3600

604800

38400 )

1.168.192.in-addr.arpa. IN NS ldap.easy.com.

254.1.168.192.in-addr.arpa. IN PTR easy.com.

253.1.168.192.in-addr.arpa. IN PTR mail.easy.com.

254.1.168.192.in-addr.arpa. IN PTR ldap.easy.com.

Setp3、OpenLDAP的詳細配置過程:

在配置OpenLDAP前,先複製samba.schema檔案到/etc/openldap/schema/目錄下(新增ldap所需要的samba認證的資料檔案到schema目錄):

詳細操作:

# cp /usr/share/doc/samb-3.0.10/LDAP/samba.schema /etc/openldap/schema/

-----------------------------------------------------------------------------------------------------------------------

說明:請一定要複製samba.schema檔案到/etc/openldap/schema目錄下, 否則在啟動ldap時會出現以下的錯誤提示資訊:

# service ldap start

檢查 的配置檔案:slaptest: bad configuration file! [失敗]

-----------------------------------------------------------------------------------------------------------------------

修改/etc/openldap/目錄中的slapd.conf檔案,主要說明修改的關鍵部分,詳細內容如下:

詳細配置內容:

include /etc/openldap/schema/core.schema

include /etc/openldap/schema/cosine.schema

include /etc/openldap/schema/inetorgperson.schema

include /etc/openldap/schema/nis.schema

部分增加以下一行內容:

include /etc/openldap/schema/samba.schema

database ldbm(定義ldap的資料庫型別)

更改為:

database bdb

suffix "dc=my-domain,dc=com" (定義ldap搜尋的域字尾)

rootdn "cn=Manager,dc= my-domain,dc=com" (定義ldap的管理DN)

更改為:

suffix "dc=easy,dc=com"

rootdn "cn=Manager,dc=easy,dc=com"

# rootpw {crypt}ijFYNcSNctBYg (設定管理DN的密碼)

更改為:

rootpw {SSHA}zW6nrZ8Muho9GOl/nAk3grt4Xqq0ZpJi

-----------------------------------------------------------------------------------------------------------------------

說明:DN管理者密碼的製造過程:

# slappasswd -h {SSHA} -s jinbiao

{SSHA}zW6nrZ8Muho9GOl/nAk3grt4Xqq0ZpJi

-----------------------------------------------------------------------------------------------------------------------

繼續slapd.conf檔案內容:

詳細配置內容:

index objectClass eq,pres

index ou,cn,mail,surname,givenname eq,pres,sub

index uidNumber,gidNumber,loginShell eq,pres

index uid,memberUid eq,pres,sub

index nisMapName,nisMapEntry eq,pres,sub

更改為:

index objectClass,uidNumber,gidNumber eq

index cn,sn,uid,displayName pres,sub,eq

index memberUid,mail,givenname eq,subinitial

index sambaSID,sambaPrimaryGroupSID,sambaDomainName eq

access to attrs=userPassword,sambaLMPassword,sambaNTPassword

by self write

by anonymous auth

by * none

access to *

by * read

-----------------------------------------------------------------------------------------------------------------------

在slapd.conf檔案最後部分新增的內容,作用為定義ldap的訪問許可權(注意書寫的格式,因為作者就是因為這個問題浪費了不少的時間和感情啦!

-----------------------------------------------------------------------------------------------------------------------

修改/etc/openldap/ldap.conf檔案內容,主要說明修改的關鍵部分:

詳細配置內容:

BASE dc=example,dc=com (更改ldap搜尋的域字尾)

更改為:

BASE dc=easy,dc=com

TLS_CACERTDIR /etc/openldap/cacerts(不使用TLS服務專案)

更改為:

# TLS_CACERTDIR /etc/openldap/cacerts

啟動OpenLDAP伺服器專案,詳細操作如下:

詳細操作:

# service ldap start

檢查 slapd 的配置檔案:config file testing succeeded

啟動 slapd: [ 確定 ]

配置linux系統使用ldap進認證過程:

詳細操作:

# setup

選擇一種工具專案中選擇:驗證配置,然後按“執行工具”鍵;

使用者資訊專案中點選“快取資訊”、“使用LDAP”;

驗證專案中點選“使用MD5口令”、“使用遮蔽口令”、“使用LDAP驗證”;

然後按“下一步”鍵;

LDAP設定:

[ ] 使用TLS (不要點選);

伺服器:127.0.0.1 (按預設地址)

基點 DN:dc=easy,dc=com (更改為:dc=easy,dc=com)

然後按“確定”鍵:

系統自動執行過程如下:

setsebool: SELinux is disabled.

停止 nscd: [ 失敗 ]

啟動 nscd: [ 確定 ]

執行後以上的操作後,將後回到“選擇一種工具”介面,按“退出”鍵完成所有ldap進認證過程。

修改/etc/openldap/ldap.conf檔案內容,主要說明修改的關鍵部分:

詳細配置內容:

TLS_CACERTDIR /etc/openldap/cacerts

更改為:

# TLS_CACERTDIR /etc/openldap/cacerts

修改/etc/ ldap.conf檔案內容,主要說明修改的關鍵部分:

詳細配置內容:

#krb5_ccname FILE:/etc/.ldapcache

新增以下內容:

#krb5_ccname FILE:/etc/.ldapcache

nss_base_passwd ou=Users,dc=easy,dc=com?one

nss_base_passwd ou=Computers,dc=easy,dc=com?one

nss_base_shadow ou=Users,dc=easy,dc=com?one

nss_base_group ou=Groups,dc=easy,dc=com?one

TLS_CACERTDIR /etc/openldap/cacerts

更改為:

# TLS_CACERTDIR /etc/openldap/cacerts

重新啟動OpenLDAP伺服器專案,詳細操作如下:

詳細操作:

# service ldap restart

停止 slapd: [ 確定 ]

檢查 slapd 的配置檔案:config file testing succeeded

啟動 slapd: [ 確定 ]

檢視OpenLDAP伺服器埠是否被監聽,詳細操作如下:

詳細操作:

# netstat -an |grep 389

tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN

tcp 0 0 :::389 :::* LISTEN

Samba的詳細配置過程:

在配置smb.conf前,先備份原smb.conf檔案:

詳細操作:

# cp /etc/samba/smb.conf /etc/samba/backup_smb.conf

Samba的主要配置檔案/etc/samba/smb.conf,其實系統中存有一個實際的例子配置檔案可提供參考,只要更換成例子檔案和按照自己的實際情況做一定的修改就可供使用:

詳細操作:

# cp /usr/share/doc/smbldap-tools-0.9.1/smb.conf /etc/samba/

cp:是否覆蓋‘/etc/samba/smb.conf’? y

修改/etc/samba/smb.conf檔案,以下為完整檔案的詳細內容::

詳細配置內容:

############################## Global parameters############################

[global]

workgroup = easy-pdc

netbios name = PDC

server string = Samba Server %v

log file = /var/log/samba/log.%m

security = user

encrypt passwords = Yes

obey pam restrictions = No

ldap passwd sync = Yes

log level = 3

syslog = 0

max log size = 100000

time server = Yes

socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

mangling method = hash2

Dos charset = UTF-8

Unix charset = UTF-8

logon script = %U.bat

logon drive = H:

domain logons = Yes

os level = 65

preferred master = Yes

domain master = Yes

繼續smb.conf檔案內容:

詳細配置內容:

passdb backend = ldapsam:ldap://127.0.0.1/

ldap admin dn = cn=Manager,dc=easy,dc=com

ldap suffix = dc=easy,dc=com

ldap group suffix = ou=Groups

ldap user suffix = ou=Users

ldap machine suffix = ou=Computers

ldap ssl = off

ldap delete dn = Yes

add user script = /sbin/smbldap-useradd -m "%u"

add machine script = /sbin/smbldap-useradd -t 0 -w "%u"

add group script = /sbin/smbldap-groupadd -p "%g"

add user to group script = /sbin/smbldap-groupmod -m "%u" "%g"

delete user from group script = /sbin/smbldap-groupmod -x "%u" "%g"

set primary group script = /sbin/smbldap-usermod -g '%g' '%u'

############################## Homes parameters ############################

[homes]

comment = repertoire de %U, %u

browseable = no

writeable = yes

read only = no

force create mode = 0700

create mode = 0700

force directory mode = 0700

directory mode = 700

############################# Netlogone parameters ##########################

[netlogon]

path = /home/netlogon/

browseable = No

read only = yes

############################# Public parameters ##########################

[public]

comment = Public Directory

path = /home/public/

browseable = No

writable = yes

guest ok = yes

create mask = 0777

-----------------------------------------------------------------------------------------------------------------------

特別提示:在網上有一些文章介紹可以實現自動建立計算機帳號的方法,不知道可否正常使用,小弟沒有試過!

操作如下在smb.conf檔案的[global]里加入以下內容(注:適合Samba 3.0版以上):

add machind script = /usr/sbin/useradd –d /dev/null –g 100 –s /bin/false –M %u

-----------------------------------------------------------------------------------------------------------------------

建立目錄和更改目錄屬性操作:

詳細操作:

# mkdir /home/netlogon

# mkdir /home/public

啟動Samba服務專案:

詳細操作:

# service smb start

啟動 SMB 服務: [ 確定 ]

啟動 NMB 服務: [ 確定 ]

新增Samba admin dn的ldap管理密碼(注意密碼要和您openldap的rootdn密碼要一致啊):

詳細操作:

# smbpasswd -w jinbiao

Setting stored password for "cn=Manager,dc=easy,dc=com" in secrets.tdb

使用testparm命令來測試Samba伺服器是否正常啟動:

詳細操作:

# testparm

Load smb config files from /etc/samba/smb.conf

Processing section "[homes]"

Processing section "[netlogon]"

Processing section "[public]"

Loaded services file OK.

Server role: ROLE_DOMAIN_PDC

Press enter to see a dump of your service definitions

Sambldap的配置使用過程:

詳細操作:

# cd /usr/share/doc/smbldap-tools-0.9.1/

# ./configure.pl

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

smbldap-tools script configuration

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Before starting, check

. if your samba controller is up and running.

. if the domain SID is defined (you can get it with the 'net getlocalsid')

. you can leave the configuration using the Crtl-c key combination

. empty value can be set with the "." character

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Looking for configuration files...

Samba Configuration File Path [/etc/samba/smb.conf] >

The default directory in which the smbldap configuration files are stored is shown.

If you need to change this, enter the full directory path, then press enter to continue.

Smbldap-tools Configuration Directory Path [/etc/smbldap-tools/] >

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Let's start configuring the smbldap-tools scripts ...

. workgroup name: name of the domain Samba act as a PDC

workgroup name [easy-pdc] >

. netbios name: netbios name of the samba controler

netbios name [PDC] >

. logon drive: local path to which the home directory will be connected (for NT Workstations). Ex: 'H:'

logon drive [H:] >

. logon home: home directory location (for Win95/98 or NT Workstation).

(use %U as username) Ex:'PDC\%U'

logon home (press the "." character if you don't want homeDirectory) [PDC\%U] >

. logon path: directory where roaming profiles are stored. Ex:'PDCprofiles\%U'

logon path (press the "." character if you don't want roaming profile) [PDCprofiles\%U] > . (輸入“.”)

. home directory prefix (use %U as username) [/home/%U] >

. default users' homeDirectory mode [700] >

. default user netlogon script (use %U as username) [%U.bat] >

default password validation time (time in days) [45] >

. ldap suffix [dc=easy,dc=com] >

. ldap group suffix [ou=Groups] >

. ldap user suffix [ou=Users] >

繼續smb.conf檔案內容:

詳細配置內容:

. ldap machine suffix [ou=Computers] >

. Idmap suffix [ou=Idmap] >

. sambaUnixIdPooldn: object where you want to store the next uidNumber

and gidNumber available for new users and groups

sambaUnixIdPooldn object (relative to ${suffix}) [sambaDomainName=easy-pdc] >

. ldap master server: IP adress or DNS name of the master (writable) ldap server

ldap master server [127.0.0.1] >

. ldap master port [389] >

. ldap master bind dn [cn=Manager,dc=easy,dc=com] >

. ldap master bind password [] > jinbiao (Samba admin dn的ldap管理密碼)

. ldap slave server: IP adress or DNS name of the slave ldap server: can also be the master one

ldap slave server [127.0.0.1] >

. ldap slave port [389] >

. ldap slave bind dn [cn=Manager,dc=easy,dc=com] >

. ldap slave bind password [] > jinbiao (Samba admin dn的ldap管理密碼)

. ldap tls support (1/0) [0] >

. SID for domain easy-pdc: SID of the domain (can be obtained with 'net getlocalsid PDC')

SID for domain easy-pdc [S-1-5-21-2425048407-535062381-2029233160] >

. unix password encryption: encryption used for unix passwords

unix password encryption (CRYPT, MD5, SMD5, SSHA, SHA) [SSHA] >

. default user gidNumber [513] >

. default computer gidNumber [515] >

. default login shell [/bin/bash] >

. default skeleton directory [/etc/skel] >

. default domain name to append to mail adress [] > easy.com

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

backup old configuration files:

/etc/smbldap-tools/smbldap.conf->/etc/smbldap-tools/smbldap.conf.old

/etc/smbldap-tools/smbldap_bind.conf->/etc/smbldap-tools/smbldap_bind.conf.old

writing new configuration file:

/etc/smbldap-tools/smbldap.conf done.

/etc/smbldap-tools/smbldap_bind.conf done.

-----------------------------------------------------------------------------------------------------------------------

說明:檢查/etc/smbldap-tools/目錄內的smbldap_bind.conf檔案以下內容要一致:

slaveDN=″cn=Manager,dc=easy,dc=com″

slavePW =″jinbiao″

masterDN=″cn=Manager,dc=easy,dc=com″

masterPW “jinbiao”

-----------------------------------------------------------------------------------------------------------------------

使用smbldap-populate命令初始化使用者服務資料庫:

詳細操作:

# smbldap-populate

Populating LDAP directory for domain easy-pdc (S-1-5-21-810223790-3119279897-2165375470)

(using builtin directory structure)

adding new entry: dc=easy,dc=com

adding new entry: ou=Users,dc=easy,dc=com

adding new entry: ou=Groups,dc=easy,dc=com

adding new entry: ou=Computers,dc=easy,dc=com

adding new entry: ou=Idmap,dc=easy,dc=com

adding new entry: uid=root,ou=Users,dc=easy,dc=com

adding new entry: uid=nobody,ou=Users,dc=easy,dc=com

adding new entry: cn=Domain Admins,ou=Groups,dc=easy,dc=com

adding new entry: cn=Domain Users,ou=Groups,dc=easy,dc=com

adding new entry: cn=Domain Guests,ou=Groups,dc=easy,dc=com

adding new entry: cn=Domain Computers,ou=Groups,dc=easy,dc=com

adding new entry: cn=Administrators,ou=Groups,dc=easy,dc=com

adding new entry: cn=Account Operators,ou=Groups,dc=easy,dc=com

adding new entry: cn=Print Operators,ou=Groups,dc=easy,dc=com

adding new entry: cn=Backup Operators,ou=Groups,dc=easy,dc=com

adding new entry: cn=Replicators,ou=Groups,dc=easy,dc=com

adding new entry: sambaDomainName=easy-pdc,dc=easy,dc=com

Please provide a password for the domain root:

Changing password for root

New password : jinbiao (admin的ldap管理密碼)

Retype new password : jinbiao (admin的ldap管理密碼)

檢視Samba的SID編號:

詳細操作:

# net getlocalsid

SID for domain EASY-PDC is: S-1-5-21-810223790-3119279897-2165375470

為Samba新增使用者和計算機名:

詳細操作:

# smbldap-useradd -a user1 (新增一個samba帳號)

# smbldap-useradd -a -m user2 (新增一個samba帳號並建立主目錄)

# smbldap-useradd -m user3 (新增一個系統使用者帳號並建立主目錄)

# smbldap-useradd -w winxp$ (新增一個域計算機帳號)

更改user2帳號的密碼:

詳細操作:

# smbldap-passwd user2

Changing password for user2

New password : 123456 (使用者密碼)

Retype new password : 123456 (確認使用者密碼)

新增user2帳號的資訊:

詳細操作:

# smbldap-userinfo user2

Changing the user information for user2

Enter the new value, or press ENTER for the default

User Shell [/bin/bash]: /bin/sh

Full Name [System User]: fan jin biao

Room Number []: 4873

Work Phone []: 013060677004

Home Phone []: 82-020-84680605

Other []: ha ha!

LDAP updated

檢視user2帳號的資訊:

詳細操作:

# smbldap-usershow user2

dn: uid=user2,ou=Users,dc=easy,dc=com

objectClass: top,inetOrgPerson,posixAccount,shadowAccount,sambaSamAccount

uid: user2

uidNumber: 1000

gidNumber: 513

homeDirectory: /home/user2

description: System User

sambaLogonTime: 0

sambaLogoffTime: 2147483647

sambaKickoffTime: 2147483647

sambaPwdCanChange: 0

displayName: System User

sambaSID: S-1-5-21-2547670411-3484865238-2904186615-3000

sambaPrimaryGroupSID: S-1-5-21-2547670411-3484865238-2904186615-513

sambaLogonScript: user2.bat

sambaHomePath: PDCuser2

sambaHomeDrive: H:

sambaLMPassword: 15881AE64C222524AAD3B435B51404EE

sambaAcctFlags: [U]

sambaNTPassword: D577561A7CF0233733F6EA39BB596996

sambaPwdLastSet: 1138015107

sambaPwdMustChange: 1141903107

userPassword: {SSHA}lSYoTrxEsxdfnMgCmxT8d72xKgdUZTVV

gecos: fan jin biao,4873,013060677004,82-020-84680605,ha ha!

cn: fan jin biao

sn: biao

givenName: fan jin

roomNumber: 4873

telephoneNumber: 013060677004

homePhone: 82-020-84680605

loginShell: /bin/sh

Samba使用者登陸除錯說明:

使用user2帳號登陸PDC伺服器:

詳細操作:

# smbclient -L 192.168.1.254 -U user2

Password:

Domain=[EASY-PDC] OS=[Unix] Server=[Samba 3.0.10-1.4E.2]

Sharename Type Comment

--------- ---- -------

IPC$ IPC IPC Service (Samba Server 3.0.10-1.4E.2)

ADMIN$ IPC IPC Service (Samba Server 3.0.10-1.4E.2)

user2 Disk repertoire de user2, user2

Domain=[EASY-PDC] OS=[Unix] Server=[Samba 3.0.10-1.4E.2]

Server Comment

--------- -------

PDC Samba Server 3.0.10-1.4E.2

Workgroup Master

--------- -------

EASY-PDC PDC

用ssh測試smbldap新增的使用者是否正確:

詳細操作:

# ssh user2@192.168.1.254

The authenticity of host '192.168.1.254 (192.168.1.254)' can't be established.

RSA key fingerprint is 37:32:c7:3f:b6:8c:d2:a6:be:8c:44:05:4c:5c:92:ed.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.1.254' (RSA) to the list of known hosts.

user2@192.168.1.254's password:

-sh-3.00$ id (輸入id,然後按Enter鍵,檢視自己的uid、gid、groups等資訊)

uid=1000(user2) gid=513(Domain Users) groups=513(Domain Users)

-sh-3.00$ exit (輸入exit,離開本次登陸)

logout

Connection to 192.168.1.254 closed.

再次檢視OpenLDAP伺服器埠是否被監聽,詳細操作如下:

詳細操作:

# netstat -an |grep 389

tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN

tcp 0 0 127.0.0.1:32805 127.0.0.1:389 ESTABLISHED

tcp 0 0 127.0.0.1:32811 127.0.0.1:389 TIME_WAIT

tcp 0 0 127.0.0.1:389 127.0.0.1:32805 ESTABLISHED

tcp 0 0 :::389 :::* LISTEN

Samba域建立Windows使用者登陸logon檔案(本例為建立user2使用者的user2.bat檔案):

使用“文字編輯器”在/home/netlogon/目錄新建user2.tmp檔案,完整內容如下:

詳細內容:

net time PDC /set /yes (客戶端與伺服器的時間同步)

net use T: PDCpublic (設定public目錄為T:盤)

將tmp檔案轉換成bat檔案(因作業系統檔案格式的不同,所以要進行一些特殊的轉換工作):

詳細內容:

# cat –A user2.tmp | tr ‘$’ ‘ ’ > user2.bat

檢視user2.bat檔案轉換結果:

詳細內容:

# cat –A user2.bat

net time PDC /set /yes^M$

net use T: PDCpublic^M$

Setp4、使用Clamav + Samba-Vscan查殺Samba伺服器內設定的共享資料夾內容:

軟體包格式:clamav-db-0.86.2-1.2.el4.rf.i386.rpm

clamav-0.86.2-1.2.el4.rf.i386.rpm

clamav-devel-0.86.2-1.2.el4.rf.i386.rpm

clamd-0.86.2-1.2.el4.rf.i386.rpm

clamav-milter-0.86.2-1.2.el4.rf.i386.rpm

軟體包的大小分別為(KB):2385KB、602KB、153KB、58KB 、66KB

下載地址:

軟體包格式: samba-vscan-clamav-0.3.6-1.i386.rpm

軟體包的大小(KB):56KB

下載地址:

安裝Clamav軟體包:

詳細操作:

# clamav-db-0.86.2-1.2.el4.rf.i386.rpm

warning: clamav-db-0.86.2-1.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 1aa78495

Preparing... ########################################### [100%]

1:clamav-db ########################################### [100%]

# clamav-0.86.2-1.2.el4.rf.i386.rpm

warning: clamav-0.86.2-1.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 1aa78495

Preparing... ########################################### [100%]

1:clamav ########################################### [100%]

# clamav-devel-0.86.2-1.2.el4.rf.i386.rpm

warning: clamd-0.86.2-1.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 1aa78495

Preparing... ########################################### [100%]

1:clamd ########################################### [100%]

# clamd-0.86.2-1.2.el4.rf.i386.rpm

warning: clamav-devel-0.86.2-1.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 1aa78495

Preparing... ########################################### [100%]

1:clamav-devel ########################################### [100%]

# clamav-milter-0.86.2-1.2.el4.rf.i386.rpm

warning: clamav-milter-0.86.2-1.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 1aa78495

Preparing... ########################################### [100%]

1:clamav-milter ########################################### [100%]

-----------------------------------------------------------------------------------------------------------------------

特別提示:請嚴格按照以上的安裝順序來安裝Clamav軟體包,否則出現安裝不成功的情況!

-----------------------------------------------------------------------------------------------------------------------

安裝Samba-Vscan軟體包:

詳細操作:

# samba-vscan-clamav-0.3.6-1.i386.rpm

warning: samba-vscan-clamav-0.3.6-1.i386.rpm: V3 DSA signature: NOKEY, key ID 6cdf2cc1

Preparing... ########################################### [100%]

1:samba-vscan-clamav ########################################### [100%]

升級病毒庫檔案:

詳細操作:

# freshclam –verbose

Current working dir is /var/clamav

Max retries == 3

ClamAV update process started at Fri Jan 27 17:37:45 2006

Querying current.cvd.clamav.net

TTL: 900

Software version from DNS: 0.88

WARNING: Your ClamAV installation is OUTDATED!

WARNING: Local version: 0.86.2 Recommended version: 0.88

DON'T PANIC! Read

main.cvd version from DNS: 35

Retrieving

Downloading main.cvd[*]

main.cvd updated (version: 35, sigs: 41649, f-level: 6, builder: tkojm)

WARNING: Your ClamAV installation is OUTDATED!

WARNING: Current functionality level = 5, recommended = 6

DON'T PANIC! Read

daily.cvd version from DNS: 1252

Retrieving

Downloading daily.cvd[*]

daily.cvd updated (version: 1252, sigs: 1513, f-level: 7, builder: diego)

WARNING: Your ClamAV installation is OUTDATED!

WARNING: Current functionality level = 5, recommended = 7

DON'T PANIC! Read

Database updated (43162 signatures) from db.cn.clamav.net (IP: 221.6.197.162)

ERROR: Clamd was NOT notified: Can't connect to clamd on 127.0.0.1:3310

connect(): Connection refused

Freeing option list...done

修改/etc/samba/目錄中的smb.conf檔案中[global]配置部分加入以下內容,完整內容如下:

詳細操作:

############################## Global parameters############################

[global]

workgroup = easy-pdc

netbios name = PDC

server string = Samba Server %v

log file = /var/log/samba/log.%m

security = user

encrypt passwords = Yes

obey pam restrictions = No

ldap passwd sync = Yes

log level = 3

syslog = 0

max log size = 100000

time server = Yes

socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

mangling method = hash2

Dos charset = UTF-8

Unix charset = UTF-8

logon script = %U.bat

logon drive = H:

domain logons = Yes

os level = 65

preferred master = Yes

domain master = Yes

passdb backend = ldapsam:ldap://127.0.0.1/

ldap admin dn = cn=Manager,dc=easy,dc=com

ldap suffix = dc=easy,dc=com

ldap group suffix = ou=Groups

ldap user suffix = ou=Users

ldap machine suffix = ou=Computers

ldap ssl = off

ldap delete dn = Yes

add user script = /sbin/smbldap-useradd -m "%u"

add machine script = /sbin/smbldap-useradd -t 0 -w "%u"

add group script = /sbin/smbldap-groupadd -p "%g"

add user to group script = /sbin/smbldap-groupmod -m "%u" "%g"

delete user from group script = /sbin/smbldap-groupmod -x "%u" "%g"

set primary group script = /sbin/smbldap-usermod -g '%g' '%u'

vfs object = vscan-clamav

vscan-oav: config-file = /etc/samba/vscan-clamav.conf

修改修改/etc/samba/目錄中的vscan-clamav.conf檔案,主要說明修改的關鍵部分,詳細內容如下:

詳細操作:

infected file action = nothing (當找到感染的檔案是否發出”警告popup 視窗”給windows)

更改為:

infected file action = quarantine

修改修改/etc/目錄中的clamd.conf檔案,主要說明修改的關鍵部分,詳細內容如下:

詳細操作:

TCPSocket 3310 (取消TCPSocket 3310)

更改為:

#TCPSocket 3310

#LocalSocket /var/run/clamav/clamd.sock (clamd socket的位置)

更改為:

LocalSocket /var/run/clamav/clamd.sock

User clamav (更改操作使用者帳號)

更改為:

User root

重新啟動Samba服務專案:

詳細操作:

# service smb restart

關閉 SMB 服務: [ 確定 ]

關閉 NMB 服務: [ 確定 ]

啟動 SMB 服務: [ 確定 ]

啟動 NMB 服務: [ 確定 ]

啟動Samba服務專案:

詳細操作:

# service clamd start

Starting Clam AntiVirus Daemon [ 確定 ]

如果看到以下的訊息表現已經成功:

詳細操作:

# tail /var/log/messages

Jan 27 17:56:10 ldap clamd[3218]: HTML support enabled.

Jan 27 17:56:10 ldap clamd[3218]: Self checking every 1800 seconds.

Jan 27 17:56:26 ldap smbd_vscan-clamav[3209]: samba-vscan (vscan-clamav 0.3.6) connected (Samba 3.0), (c) by Rainer Link, OpenAntiVirus.org

Jan 27 17:56:26 ldap smbd_vscan-clamav[3209]: INFO: connect to service IPC$ by user nobody

Jan 27 17:56:26 ldap smbd_vscan-clamav[3209]: INFO: disconnected

Jan 27 17:56:26 ldap smbd_vscan-clamav[3209]: samba-vscan (vscan-clamav 0.3.6) connected (Samba 3.0), (c) by Rainer Link, OpenAntiVirus.org

Jan 27 17:56:26 ldap smbd_vscan-clamav[3209]: INFO: connect to service IPC$ by user user2

Jan 27 17:56:26 ldap smbd_vscan-clamav[3209]: samba-vscan (vscan-clamav 0.3.6) connected (Samba 3.0), (c) by Rainer Link, OpenAntiVirus.org

Jan 27 17:56:26 ldap smbd_vscan-clamav[3209]: INFO: connect to service IPC$ by user nobody

Jan 27 17:56:37 ldap smbd_vscan-clamav[3209]: INFO: disconnected

Setp5、使用LDAP Browser/Editor客戶端來管理OpenLdap中的資料:

-----------------------------------------------------------------------------------------------------------------------

特別提示:LDAP Browser/Editor軟體,需要在jdk 環境下才能執行。所以要安裝jdk-1.5.0_04軟體包才可以使LDAP Browser/Editor軟體正常工作!

-----------------------------------------------------------------------------------------------------------------------

軟體包格式:jdk-1_5_0_04-linux-i586-rpm.bin

軟體包的大小(KB):45858KB

下載地址:

軟體包格式:Browser282b2.tar.gz

軟體包的大小(KB):637KB

下載地址:~gawojar/ldap/

安裝LDAP Browser/Editor前,請先安裝jdk軟體包:

詳細操作:

# chmod 755 jdk-1_5_0_04-linux-i586-rpm.bin(更改檔案的執行許可權)

# ./jdk-1_5_0_04-linux-i586-rpm.bin(編譯檔案,檢視版權說明過程)

# rpm -ivh jdk-1_5_0_04-linux-i586.rpm(開始安裝檔案)

Preparing... ############################################ [100%]

package jdk-1.5.0_04-fcs is already installed

修改/etc/目錄中的profile檔案(在profile檔案的最後面加入以下的資訊):

詳細操作:

JAVA_HOME=/usr/java/jdk1.5.0_04

PATH=$JAVA_HOME/bin:$PATH

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export JAVA_HOME,PATH,CLASSPATH

修改完/etc/目錄中的profile檔案後,重新啟動RedHat Enterprise Linux Server 4.2作業系統:

詳細操作:

# reboot

LDAP Browser/Editor軟體包詳細安裝過程:

詳細操作:

# tar -zxvf Browser282b2.tar.gz -C /root/

以下操作請回到桌面環境進行,點選工作列中“應用程式” → “檔案瀏覽器”;

進入Browser282b2應用程式的解壓目錄,“/root/ldapbrowser”→ 雙擊“lbe.sh”執行程式;

lbe.sh程式執行時,系統會出現一個提示 “執行還是顯示”資訊視窗內容如下:

可點選“在終端中執行(T)”或者“執行(R)”兩按鍵中的其中之一;

接著出現“Connect” → “Edit”按鍵;

出現“Edit Session”資訊視窗,點選“Name”選擇框:

Name:Easy-PDC (隨著輸入一個名稱)

點選“Connection”選擇框:

Host:127.0.01 (輸入ldap伺服器的主機地址);

Port:389 (輸入訪問ldap伺服器的埠);

Version:2 (選擇ldap伺服器的版本);

Base DN:dc=easy,dc=com (輸入ldap伺服器的DN地址:dc=easy,dc=com);

User DN:cn=Manager,dc=easy,dc=com (輸入管理ldap伺服器的使用者名稱);

Password:jinbiao (輸入管理ldap伺服器的使用者密碼);

點選“Save”按鍵;

完成 “Edit Session”資訊視窗相關內容修改後 → 重新回到“Connect”資訊視窗 → 點選“Connect”按鍵;

在配置 “Edit Session”資訊視窗相關內容時,沒有發生什麼修改錯誤的話。應就會跟小弟的系統一樣出現以下成功登入資訊視窗;

到這為止,就完成Browser282b2軟體的所有配置工作!

Setp9、Postfix主機安裝RedHat Enterprise Linux Server 4.2作業系統截圖:

磁碟配置:

裝置 型別 大小

/ ext3 39911

swap 1024

網路基本配置:

etho IP/Gateway:192.168.1.253/255.255.255.0

主機名:mail.easy.com

閘道器:192.168.1.1

主/次DNS:192.168.1.254/192.168.1.253/202.96.128.68

防火牆基本配置:

⊙ 無防火牆

⊙ 是否啟用 SELinux:已禁用

安裝方式的選項:

⊙ 定製要安裝的軟體包(C)

桌面選項:

(√) X視窗系統 (選取全部)

(√) GNOME桌面環境 (選取全部)

應用程式選項:

(√) 工程和科學 (選取預設)

(√) 圖形化網際網路 (選取預設)

(√) 基於文字的網際網路 (選取預設)

(√) 辦公/生產率 (選取預設)

伺服器選項:

(√) 伺服器配置工具 (選取全部)

(√) 全球資訊網伺服器 (選取全部)

(√) 郵件伺服器(自行選全部)

(√) Windows檔案伺服器 (選取全部)

(√) SQL資料庫 (選取全部)

郵件伺服器的細節選項:

(√) perl-Cyrus - Cyrus IMAP server utility Perl modules.

(√) spamassassin - Spam filter for email which can be invoked from mail delivery age...

開發選項:

(√) 開發工具 (選擇全部)

系統選項:

(√) 管理工具 (選取預設)

(√) 列印支援 (選取預設)

雜項選項:

全部不要選擇;

Step6、Postfix軟體包安裝和配置過程:

軟體包格式:postfix-2.2.5-1.mysql.sasl2.vda.rhel4.i386.rpm

特別說明:本軟體包預設以支援LDAP、MySQL、SASL、VDA、TLS等功能;

軟體包的大小(KB):3408KB

下載地址:http://www.proficuous.com/postfix/4...ex_4_2.2.5.html

安裝Postfix前,請先刪除系統安裝時所自帶的Sendmail軟體包:

詳細操作:

# service sendmail stop (停止sendmail系統的執行)

# rpm -e sendmail --nodeps (從作業系統中刪除sendmail軟體包)

Postfix軟體包詳細安裝過程:

詳細操作:

# rpm -ivh postfix-2.2.5-1.mysql.sasl2.vda.rhel4.i386.rpm (安裝postfix軟體包)

Preparing... ########################################### [100%]

1:postfix ########################################### [100%]

查詢postfix使用者和所屬組的ID資料:

詳細操作:

# id postfix (查詢postfix使用者、所屬組的ID)

uid=102(postfix) gid=103(postfix) groups=103(postfix),12(mail)

使用者ID:102 所屬組ID:103

使用postalias命令建立aliases.db檔案:

詳細操作:

# cd /etc/

# postalias aliases (建立aliases.db檔案)

Setp10、Windows XP SP2英文版作業系統加入Samba域詳細說明:

在Windows XP SP2加入SMB域之前,請先執行以下的兩個註冊檔案:

A、 WinXP_PlainPassword.reg

B、 WinXP_SignOrSeal.reg

-----------------------------------------------------------------------------------------------------------------------

說明:WinXP_PlainPassword.reg、WinXP_SignOrSeal.reg這兩個檔案可以在/usr/share/doc/samba

-3.0.10/registry/目錄查詢到!

-----------------------------------------------------------------------------------------------------------------------

完成WinXP_PlainPassword.reg、WinXP_SignOrSeal.reg兩個註冊檔案的安裝工作後,點選“我的電腦” → “屬性”,出現“系統屬性”視窗;

點選“計算機名” → “網路標識” → “更改(C)...”;

出現“計算機名稱更改”屬性視窗:

“隸屬於” → “域(D):” 輸入easy-pdc;(sambaDomain Namep定義域名);

出現新的“計算機名更改”資訊視窗;

請輸入有加入該域許可權的帳戶的名稱和密碼:

使用者名稱(U):root

密碼(P):jinbiao

如果輸入的“計算機名(C):”和“域(D):”正確,經過一小段時間就會出現“歡迎加入easy-pdc域”的資訊視窗;

關閉“歡迎加入easy-pdc域”的資訊視窗,按“確定”鍵,接著出現新的提示視窗“要使更改生效,必須重新啟動計算機”資訊視窗;

關閉“要使更改生效,必須重新啟動計算機”資訊視窗。回到“系統屬性”視窗,按“確定”鍵,關閉“系統屬性”視窗;

接著出現“系統設定改變”資訊視窗,提示“必須重新啟動計算機才能使新設定生效,想現在重新啟動計算機嗎?”,按“是(Y)”鍵,關閉“系統設定改變”資訊視窗;

到這為止,就完成Windows XP SP2英文版作業系統加入Samba域的工作!

完成重新啟動後,出現第一個資訊“Welcome to Windows”視窗:

根據資訊提示同時按“Ctrl” + “Alt” + “Delete”三個按鍵,出現“Log On to Windows” 視窗:

在“Log On to Windows” 視窗中點選“Options >>”按鍵;

現在可以試一下輸入以下的使用者資訊登陸到Easy-PDC網域內:

User name:user2

Password:123456

Log on to:EASY-PDC

登陸作業系統後,桌面環境(一片空白);

在桌面內,按“Mouse”右鍵,“Properties”;

出現“Display Properties”視窗

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29514088/viewspace-1378784/,如需轉載,請註明出處,否則將追究法律責任。

相關文章