postfix+dovecot+courierauthlib+win AD.docx

您所在的位置:网站首页 云盘上传的文件传到什么地方去了怎么查 postfix+dovecot+courierauthlib+win AD.docx

postfix+dovecot+courierauthlib+win AD.docx

#postfix+dovecot+courierauthlib+win AD.docx| 来源: 网络整理| 查看: 265

postfix+dovecot+courierauthlib+win AD.docx

《postfix+dovecot+courierauthlib+win AD.docx》由会员分享,可在线阅读,更多相关《postfix+dovecot+courierauthlib+win AD.docx(15页珍藏版)》请在冰豆网上搜索。

postfix+dovecot+courierauthlib+win AD.docx

postfix+dovecot+courierauthlib+winAD

postfix+courier-imap+authlib+winAD+extmail

注:

在这里因为尝试过很多次dovecot但是配置不成功,所以这里用的courier-imap来取代dovecot,理论上dovecot应该是可以的。

一、所需软件及其用途:

1、postfix:

作为邮件的MTA软件,负责邮件的进、出(server-server/client-server)

2、authlib:

postfix调用authlib来查询AD进行用户密码和密码认证。

3、dovecot:

提供pop3和imap邮件功能(也可以使用courier-imap).

4、openldap:

需要客户端及开发库文件

5、extmail:

extmail需要很多perl模块

6、apache和php

7、cyrus-saslpostfix通过sasl来查询authlib进行密码查询与验证。

版本:

 

1、openldap

openldap-devel-2.3.43-25.el5

openldap-clients-2.3.43-25.el5

openldap-2.3.43-25.el5

2、cyrus-sasl 

cyrus-sasl-plain-2.1.22-5.el5_4.3

cyrus-sasl-lib-2.1.22-5.el5_4.3

cyrus-sasl-devel-2.1.22-5.el5_4.3

cyrus-sasl-ldap-2.1.22-5.el5_4.3

cyrus-sasl-2.1.22-5.el5_4.3

cyrus-sasl-md5-2.1.22-5.el5_4.3

3、postfix 

postfix-2.3.3-2.1

4、authlib

courier-authlib-0.64.0

5、extmail

extmail-1.1.1.tar.gz

二、WindowsAD设置

1、建立mailuser的OU,并在其下建立extmail用户密码123456

二、安装应用程序

1、openldap

#yuminstallopenldapopenldap-clientsopenldap-devel

2、authlib

#./configure--with-authldap–without-authmysql–without-authpgsql (这里最好不要加上—prefix=xxxx,直接这样编译,更改路径可能使后面的courier-imap找不到该程序)

#make

#makeinstall

#makeinstall-configure

将authlib添加到服务

#cp./courier-authlib.sysvinit/etc/init.d/authlibd

#chkconfigauthlibdon

#serviceauthlibdstart

3、postfix

这里安装方法请参考我的postfix+dovecot+extmail文档

完成后可运行如下命令检查编入的模块:

dovecot

#postconf -a 

dovecot

#postconf–m

ldap

4、dovecot

yuminstalldovecot

5、apache和php可以通过yuminstall来安装。

四、配置authlib查询windowsad的LDAP认证。

#cd/usr/local/etc/authlib/

authdaemonrc的内容如下:

[root@mailauthlib]#catauthdaemonrc|grep-v"^#" 

authmodulelist="authldap" 

authmodulelistorig="authldap" 

daemons=5 

authdaemonvar=/usr/local/var/spool/authdaemon 

#请注意authdaemon文件的路径及权限要求postfix的运行帐户有执行的权限。

该目录权限一定要改成755

DEBUG_LOGIN=2 

DEFAULTOPTIONS="" 

LOGGEROPTS=""

#chmod755/usr/local/var/spool/authdaemon(这个目录权限不对的话,可能导致后面sasl认证不成功,并且使extmail无法正常登陆)

配置authldaprc文件进行WINDOWSAD查询。

请注意配置文件的格式为“变量[空格或TAB]值”无论在行首或行未不要有任何多余的空格。

[root@mailauthlib]#catauthldaprc|grep-v"^#" 

LDAP_URIldap:

//192.168.2.150

LDAP_PROTOCOL_VERSION3

LDAP_BASEDNou=mailuser,dc=mytest,dc=com

LDAP_BINDDNextmail@

LDAP_BINDPW123456

LDAP_TIMEOUT5

LDAP_AUTHBIND1

LDAP_MAILmail

LDAP_FILTER(&(objectClass=person)(!

(userAccountControl=66050)))

LDAP_DOMAIN

LDAP_GLOB_UIDpostfix

LDAP_GLOB_GIDpostfix

LDAP_HOMEDIRsAMAccountName

LDAP_MAILROOT/mailbox

LDAP_MAILDIRMaildir

LDAP_DEFAULTDELIVERYdefaultDelivery

LDAP_MAILDIRQUOTAmailmessagestore

LDAP_FULLNAMEdisplayName

LDAP_CRYPTPWuserPassword

LDAP_DEREFnever

LDAP_TLS0

注意:

1、BASE_DN一定要指定一个明确的OU值,如果您用dc=mytest,dc=com则会出现无法查询到任何帐户

2、BIND_DN中extmail@ extmail是您在WindowsAD的mailuser这个OU下面建立的帐户。

是您的WINDOWSAD的域名。

3、LDAP_MAIL和LDAP_FILTER是通过ldap查询时的过滤规则同mail一起使用,本文的通过authlib后就成为:

(&(&(objectClass=person)(!

(userAccountControl=66050)))(mail=username'semailaddress))

4、LDAP_GLOB_UID和GID参数的使用者帐户必须要与postfix的和extmail的一至,否则会出现chdrMaildir错误。

5、LDAP_HOMEDIR这个参数这里要注意,一般的“用户家目录”格式如下:

/mailbox/test/Maildir(您的可能会不一样),其它/data/vmail为邮件的根目录,test为用户的“家目录”,Maildir这个参数会自动在courier-imap中pop3d这个配置文件中指定MAILDIRPATH=Maildir.

下面开始配置courier-IMAP的POP3和IMAP功能(extmail只使用了pop3功能,所以可以不用配置imap)

#cd/etc

#cat/etc/dovecot.conf|grep-v^$|grep-v^#

protocols=imappop3

listen=*

mail_location=maildir:

/mailbox/%u/Maildir

protocolimap{

}

protocolpop3{

pop3_client_workarounds=outlook-no-nulsoe-ns-eoh

}

protocollda{

auth_sock_path=/var/run/dovecot/auth-master

postmaster_address=extmail@

hostname=192.168.2.150

}

authdefault{

mechanisms=plainlogin

username_format=%Lu

passdbldap{

args=/etc/dovecot-ldap.conf

}

userdbstatic{

args=uid=1000gid=1000home=/mailbox/%u

}

user=root

socketlisten{

master{

path=/var/run/dovecot/auth-master

mode=0600

}

client{

path=/var/run/dovecot/auth-client//这里的配置需要跟postfix里的smtpd_sasl_path对应

mode=0660

user=postfix

group=postfix

}

}

}

增加dove-ldap.conf

#cat/etc/dovecot-ldap.conf

hosts=192.168.2.150

dn=extmail@

auth_bind=yes

dnpass=123456

auth_bind_userdn=mytest\%u

ldap_version=3

base=dc=mytest,dc=com

scope=subtree

deref=never

user_filter=(&(objectClass=person)(sAMAccountName=%u))

pass_attrs=(&sAMAccountName=%u)(userPassword=password))

pass_filter=(&objectClass=person)(SAMAccount=%u))

default_pass_scheme=CRYPT

OK,基本的POP3认证auhlib就成功了,现在我们测试一下。

在开始测试test用户之前我们需要确认在WINDOWSAD中extmail用户的邮件地址已经写为extmail@ 了。

如下图:

#authtest-sloginextmail123456

Authenticationsucceeded.

Authenticated:

extmail(uid1000,gid1000)

HomeDirectory:

/mailbox/extmail

Maildir:

(none)

Quota:

(none)

EncryptedPassword:

(none)

CleartextPassword:

123456

Options:

(none)

出现以上提示说明配置成功了,如果失败最大的可能就是你的authldaprc

文件中的语法不正确或多了一个或多个空格。

四、配置postfix与sasl2。

1、增加smtpd.conf文件

#cat/usr/lib/sasl2/smtpd.conf

pwcheck_method:

authdaemond

log_level:

3

mech_list:

PLAINLOGIN

authdaemond_path:

/usr/local/var/spool/authdaemon/socket

2、修改postfix的main.cf配置文件

#cat/etc/postfix/main.cf|grep-v^#

alias_database=hash:

/etc/aliases

alias_maps=hash:

/etc/aliases

broken_sasl_auth_clients=yes

command_directory=/usr/sbin

config_directory=/etc/postfix

daemon_directory=/usr/libexec/postfix

debug_peer_level=2

home_mailbox=Maildir/

html_directory=no

mail_owner=postfix

mailq_path=/usr/bin/mailq.postfix

manpage_directory=/usr/share/man

mydomain=

myhostname=

mynetworks=192.168.2.0/24,127.0.0.0/8

myorigin=$mydomain

inet_interfaces=all

newaliases_path=/usr/bin/newaliases.postfix

queue_directory=/var/spool/postfix

readme_directory=/usr/share/doc/postfix-2.1.5/README_FILES

sample_directory=/usr/share/doc/postfix-2.1.5/samples

sendmail_path=/usr/sbin/sendmail.postfix

setgid_group=postdrop

smtpd_sasl_type=dovecot

smtpd_sasl_path=/var/run/dovecot/auth-client

unknown_local_recipient_reject_code=550

virtual_mailbox_base=/mailbox

virtual_transport=virtual

virtual_uid_maps=static:

1000

virtual_gid_maps=static:

1000

message_size_limit=14336000

virtual_mailbox_limit=20971520

virtual_alias_maps=ldap:

/etc/postfix/ldap-group.cf

virtual_mailbox_domains=$mydomain

virtual_mailbox_maps=ldap:

/etc/postfix/ldap-users.cf

broken_sasl_auth_clients=yes

smtpd_recipient_restrictions=

permit_mynetworks,

permit_sasl_authenticated,

reject_unauth_destination,

permit

smtpd_sasl_auth_enable=yes

smtpd_sasl_local_domain=$myhostname

smtpd_sasl_security_options=noanonymous

smtpd_banner=$myhostnameESMTP"VersionnotAvailable"

#cat/etc/postfix/ldap-users.cf

server_host=192.168.2.150

search_base=dc=mytest,dc=com

version=3

query_filter=(&(objectclass=person)(|(mail=%s)(othermailbox=%s))(!

(userAccountControl=66050)))

bind=yes

bind_dn=extmail@

bind_pw=123456

result_attribute=samaccountname

result_format=%u/Maildir/

cat/etc/postfix/ldap-group.cf

server_host=192.168.2.150

search_base=dc=mytest,dc=com

version=3

query_filter=(&(objectClass=group)(mail=%s))

leaf_result_attribute=mail

special_result_attribute=member

bind=yes

bind_dn=extmail@

bind_pw=123456

五、配置extmail(在之前请确认已经设置好apache及php并且把apache的user和group设置为postfix用户)

cat/var/www/extsuite/extmail/webmail.cf|grep-v^$|grep-v^#

SYS_CONFIG=/var/www/extsuite/extmail/

SYS_LANGDIR=/var/www/extsuite/extmail/lang

SYS_TEMPLDIR=/var/www/extsuite/extmail/html

SYS_HTTP_CACHE=0

SYS_SMTP_HOST=127.0.0.1

SYS_SMTP_PORT=25

SYS_SMTP_TIMEOUT=5

SYS_SPAM_REPORT_ON=0

SYS_SPAM_REPORT_TYPE=dspam

SYS_SHOW_WARN=0

SYS_IP_SECURITY_ON=1

SYS_PERMIT_NOQUOTA=1

SYS_SESS_DIR=/tmp

SYS_UPLOAD_TMPDIR=/tmp

SYS_LOG_ON=1

SYS_LOG_TYPE=file

SYS_LOG_FILE=/var/log/extmail.log

SYS_SESS_TIMEOUT=0

SYS_SESS_COOKIE_ONLY=1

SYS_USER_PSIZE=10

SYS_USER_SCREEN=auto

SYS_USER_LANG=en_US

SYS_APP_TYPE=WebMail

SYS_USER_TEMPLATE=default

SYS_USER_CHARSET=utf-8

SYS_USER_TRYLOCAL=1

SYS_USER_TIMEZONE=+0800

SYS_USER_CCSENT=1

SYS_USER_SHOW_HTML=1

SYS_USER_COMPOSE_HTML=1

SYS_USER_CONV_LINK=1

SYS_USER_ADDR2ABOOK=1

SYS_MESSAGE_SIZE_LIMIT=5242880

SYS_MIN_PASS_LEN=2

SYS_MFILTER_ON=1

SYS_NETDISK_ON=1

SYS_SHOW_SIGNUP=0

SYS_DEBUG_ON=1

SYS_AUTH_TYPE=authlib

#SYS_MAILDIR_BASE=/mailbox

SYS_AUTH_SCHEMA=virtual

SYS_CRYPT_TYPE=md5crypt

SYS_AUTHLIB_SOCKET=/usr/local/var/spool/authdaemon/socket

SYS_G_ABOOK_TYPE=file

SYS_G_ABOOK_LDAP_HOST=192.168.2.150

SYS_G_ABOOK_LDAP_BASE=ou=mailuser,dc=mytest,dc=com

SYS_G_ABOOK_LDAP_ROOTDN=cn=extmail,ou=mailuser,dc=mytest,dc=com

SYS_G_ABOOK_LDAP_ROOTPW=123456

SYS_G_ABOOK_LDAP_FILTER=objectClass=OfficePerson

SYS_G_ABOOK_FILE_PATH=/var/www/extsuite/extmail/globabook.cf

SYS_G_ABOOK_FILE_LOCK=1

SYS_G_ABOOK_FILE_CONVERT=0

SYS_G_ABOOK_FILE_CHARSET=utf-8

注意:

1.修改黑体字的SYS_AUTHLIB_SOCKET为您的authdaemond配置文件中的路径一至,并且要授予权限chmod755/usr/local/var/spool/authdaemon 

2.红色字体部分一定要注释掉,因为这个路径在authlib的authldaprc文件中定义过了。

Extmail会根据authlib定义的路径去查找邮件,不注释掉会出现错误

3.配置成AD认证以后,邮件服务器没有注册的功能,所以将SYS_SHOW_SIGNUP设为0,即不显示注册的按钮

五、确认与测试

1、确认postfix的SMTP启用了PLAIN和LOGIN认证功能

#serviceauthlibstart

#servicepostfixstart

测试SMTP发信功能:

2、测试POP3功能

3、用客户端软件对pop3和SMTP功能进行测试

具体配置请查看先前文档postfix+dovecot+extmail

4、测试EXTMAIL是否成功:

进入后的界面



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3