Postfix + Exchange + ActiveDirectory; 如何混合他们

我的客户有许多子办事处和一个总部。 总部有一个域名: business.com

在许多子办公室中的所有用户都需要有一个总部电子邮件地址: [email protected]任何不在总部的人都需要将电子邮件转发到外部电子邮件地址。 总部的所有用户都将他们的电子邮件传送到Microsoft Exchange。 用户在Active Directory中列在两个不同的OU: HeadOfficeSubOffice

这是否能够被configuration? 我已经做了一些Googlesearch,但我找不到任何例子或企业设置这种方式。

编辑:Postfix将接受所有的电子邮件,将需要确定将电子邮件转发到外部帐户,或者将其交付到MS Exchange。

我已经做了一些关于MS Exchange的阅读,并且您可以通过邮件启用联系人进行转发 – 但是我不知道每个AD帐户是否需要Exchange CAL?

最终目标是将电子邮件转发到分支机构的外部账户或接受总部的电子邮件。

也许我不需要担心Postfix执行这个任务…..

http://www.windowsitpro.com/article/exchange-server-2010/exchange-server-licensing-some-of-your-questions-answered

“客户端访问许可证(CAL)如何?每个连接到Exchange的用户都需要一个CAL,虽然可能不是百分之百准确,但我更愿意将其视为每个邮箱一个CAL;对于您以外的用户组织,使用邮箱的自动化工具等等,Exchange并没有强制执行这个限制,所以你要确保你拥有正确数量的CAL来支持你所支持的客户端。

虽然不是严格地回答你的问题,但你想要实现的东西应该相当简单,只需要对下面的perl脚本进行一些修改即可。

perl脚本查询活动目录,并返回与脚本中的模式相匹配的指定OU中的电子邮件地址列表,然后重新生成postfix用来确定需要接受电子邮件的有效电子邮件地址的configuration文件。

perl脚本由一个bash脚本调用,它是通过cron启动的。

通过一些工作,对脚本进行调整应该相当容易,以便能够执行所需的操作。

请注意,您将需要使用perl脚本中指定的详细信息在AD中创build一个用户,并且该用户帐户需要读取AD中相关对象的读取权限。

$hqbase确定将search电子邮件地址的容器。

创build下面的bash脚本,它是通过cron启动的:

 #!/bin/bash # Get the email addresses from AD, if it fails exit the script /root/getadsmtp.pl || exit # Now convert the list into a file that postfix can understand /usr/sbin/postmap /etc/postfix/exchange_recipients 

以下是从上面的shell脚本调用的文件getadsmtp.pl。 你将需要修改这个来获得你正在寻找的结果。

 use Net::LDAP; use Net::LDAP::Control::Paged; use Net::LDAP::Constant ( "LDAP_CONTROL_PAGED" ); $VALID = "/etc/postfix/exchange_recipients"; $dc1="dc1.example.local"; $dc2="dc2.example.local"; $hqbase="ou=foo,dc=example,dc=com"; $user="cn=postfix_xfer,ou=Services,ou=users,ou=foo,dc=example,dc=com"; $passwd="passwordgoeshere"; $noldapserver=0; $ldap = Net::LDAP->new($dc1) or $noldapserver=1; if ($noldapserver == 1) { $ldap = Net::LDAP->new($dc2) or die "Error connecting to specified domain controllers $@ \n"; } $mesg = $ldap->bind ( dn => $user, password =>$passwd); if ( $mesg->code()) { die ("error:", $mesg->code(),"\n","error name: ",$mesg->error_name(), "\n", "error text: ",$mesg->error_text(),"\n"); } $page = Net::LDAP::Control::Paged->new( size => 990 ); @args = ( base => $hqbase, filter => "(& (mailnickname=*) (| (&(objectCategory=person) (objectClass=user)(!(homeMDB=*))(!(msExchHomeServerName=*))) (&(objectCategory=person)(objectClass=user)(|(homeMDB=*) (msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=contact)) (objectCategory=group)(objectCategory=publicFolder)(objectClass=msExchDynamicDistributionList) ))", control => [ $page ], attrs => "proxyAddresses", ); my $cookie; while(1) { # Perform search my $mesg = $ldap->search( @args ); foreach my $entry ( $mesg->entries ) { my $name = $entry->get_value( "cn" ); # LDAP Attributes are multi-valued, so we have to print each one. foreach my $mail ( $entry->get_value( "proxyAddresses" ) ) { # Test if the Line starts with one of the following lines: # proxyAddresses: [smtp|SMTP]: # and also discard this starting string, so that $mail is only the # address without any other characters... if ( ( $mail =~ s/^(smtp|SMTP)://gs ) && ( ( $mail =~ m/example.co.uk/ ) || ( $mail =~ m/example.com/ ) || ( $mail =~ m/example.org/ ) || ( $mail =~ m/example.net/ ) ) ) { push(@valid, $mail." OK\n"); } } } # Only continue on LDAP_SUCCESS $mesg->code and last; # Get cookie from paged control my($resp) = $mesg->control( LDAP_CONTROL_PAGED ) or last; $cookie = $resp->cookie or last; # Set cookie in paged control $page->cookie($cookie); } if ($cookie) { # We had an abnormal exit, so let the server know we do not want any more $page->cookie($cookie); $page->size(0); $ldap->search( @args ); # Also would be a good idea to die unhappily and inform OP at this point die("LDAP query unsuccessful"); } open VALID, ">$VALID" or die "CANNOT OPEN $VALID $!"; print VALID @valid; close VALID; 

希望这会对你有所帮助。