Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Postfix: Forward email and local delivery with LDAP
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
ckoeber
Apprentice
Apprentice


Joined: 21 May 2007
Posts: 156

PostPosted: Fri Oct 22, 2010 2:16 am    Post subject: [SOLVED] Postfix: Forward email and local delivery with LDAP Reply with quote

[SOLVED]

Hello,

I would like for a user to have the ability to forward email to an external account BUT I also need to keep a copy of that message using PostfFix. So, I have the following template that I believe can work for an alias file for an LDAP setup:

ldap-alias.cf:

Code:
 
server_host = [LDAP Server here]
search_base = [Search Base Here]
version=3
timeout = 10
bind = yes
bind_dn = [bind-dn here]
bind_pw = [bind password here]
query_filter = (mail=%s)
result_attribute = (local account?) + (forwarding account?)


Now, I have a separate attribute called vacationForward within my LDAP system that contains the forwarding address. My local email address is stored as mail within LDAP.

The problem is that I would need to return TWO results, correct? I need to return the local account and the forwarding account, correct?

Has anyone done this with Postfix?

Thanks for any help with this.


Last edited by ckoeber on Fri Oct 22, 2010 6:14 pm; edited 1 time in total
Back to top
View user's profile Send private message
nativemad
Developer
Developer


Joined: 30 Aug 2004
Posts: 827
Location: Switzerland

PostPosted: Fri Oct 22, 2010 5:10 am    Post subject: Reply with quote

Hi,

the alias query should return a comma separated list of destination addresses... Therefore you would need a third account for the local delivery or you'll see some looping i suppose!?

I made such things in the maildrop-delivery script. You think you should also be able to do it with procmail or such.

good luck
_________________
Power to the people!
Back to top
View user's profile Send private message
ckoeber
Apprentice
Apprentice


Joined: 21 May 2007
Posts: 156

PostPosted: Fri Oct 22, 2010 6:12 pm    Post subject: Reply with quote

nativemad wrote:
Hi,

the alias query should return a comma separated list of destination addresses... Therefore you would need a third account for the local delivery or you'll see some looping i suppose!?

I made such things in the maildrop-delivery script. You think you should also be able to do it with procmail or such.

good luck


Thanks for the help, I figured this out. Your suggestion was close to the mark!

I am posting a separate reply for other people.
Back to top
View user's profile Send private message
ckoeber
Apprentice
Apprentice


Joined: 21 May 2007
Posts: 156

PostPosted: Fri Oct 22, 2010 6:15 pm    Post subject: Reply with quote

OK, so I figured this out:

To forward email and retain a local copy with LDAP, here is tutorial configuration:

Put the text below (with your modifications) in a file, preferably in the same directory where other Postfix configuration files are.

----------------------
Code:
server_host = [LDAP HOST]
search_base = [Search Base - i.e. (ou=Where to Search,dc=example,dc=com)]
version=3
timeout = 10
size_limit = 1      (Directive to inform the LDAP searching utility that only one SET of results should come back per search (i.e. if I search for one CN then only one CN with all resultant attributes should be returned.)
bind = yes
bind_dn = [Bind DN for searching]
bind_pw = [Bind Password]
query_filter = ([Attribute to search for here]=%s)                  - Note that this is the address of the email being recieved.
result_attribute = [Attribute Containing Local Address], [Attribute Containing External Address], [More Attributes containing addresses, separated by commas]
----------------------

Once this is done, put your ldap:[Location of above file] directive within a virtual_alias_maps or alias_maps directive in your main configuration file. This depends on whether the address being delivered to is read as a local or virtual domain. A completely working example looks something like what I have below:

ldap-forward-example.cf:
----------------------
Code:
server_host = ldap-server.example.com
search_base = ou=People,dc=example,dc=com
version=3
timeout = 10
size_limit = 1
bind = yes
bind_dn = cn=Manager,dc=example,dc=com
bind_pw = password
query_filter = (mail=%s)
result_attribute = mail, addressToForward
----------------------

Within the main.cf file:

----------------------
Code:
#For virtual domains:
virtual_alias_maps = ldap:/etc/postfix/ldap-forward-example.cf
#
# OR
#
#For local domains:
alias_maps = hash:/etc/mail/aliases,ldap:/etc/postfix/ldap-forward-example.cf

----------------------
That should be it. Hope this helps someone. I have been searching all over for this.


Last edited by ckoeber on Sat Oct 23, 2010 5:42 pm; edited 1 time in total
Back to top
View user's profile Send private message
nativemad
Developer
Developer


Joined: 30 Aug 2004
Posts: 827
Location: Switzerland

PostPosted: Sat Oct 23, 2010 2:38 pm    Post subject: Reply with quote

ok, nice trick with the "mail, field"! :P
I've got almost the same, but without a local copy... postalias is my field with the comma separated list as value
Code:
result_attribute = postalias

_________________
Power to the people!
Back to top
View user's profile Send private message
seyazar
n00b
n00b


Joined: 23 Aug 2011
Posts: 1

PostPosted: Tue Aug 23, 2011 1:20 pm    Post subject: postfix ldap forwarding Reply with quote

Hi,

i applied these settings and it's worked, but after that i create ne schema element for forward address(first i used description attribute), now it doesn't work how can i investigate this or debug ?

thanks in advance.

Selçuk


ckoeber wrote:
OK, so I figured this out:

To forward email and retain a local copy with LDAP, here is tutorial configuration:

Put the text below (with your modifications) in a file, preferably in the same directory where other Postfix configuration files are.

----------------------
Code:
server_host = [LDAP HOST]
search_base = [Search Base - i.e. (ou=Where to Search,dc=example,dc=com)]
version=3
timeout = 10
size_limit = 1      (Directive to inform the LDAP searching utility that only one SET of results should come back per search (i.e. if I search for one CN then only one CN with all resultant attributes should be returned.)
bind = yes
bind_dn = [Bind DN for searching]
bind_pw = [Bind Password]
query_filter = ([Attribute to search for here]=%s)                  - Note that this is the address of the email being recieved.
result_attribute = [Attribute Containing Local Address], [Attribute Containing External Address], [More Attributes containing addresses, separated by commas]
----------------------

Once this is done, put your ldap:[Location of above file] directive within a virtual_alias_maps or alias_maps directive in your main configuration file. This depends on whether the address being delivered to is read as a local or virtual domain. A completely working example looks something like what I have below:

ldap-forward-example.cf:
----------------------
Code:
server_host = ldap-server.example.com
search_base = ou=People,dc=example,dc=com
version=3
timeout = 10
size_limit = 1
bind = yes
bind_dn = cn=Manager,dc=example,dc=com
bind_pw = password
query_filter = (mail=%s)
result_attribute = mail, addressToForward
----------------------

Within the main.cf file:

----------------------
Code:
#For virtual domains:
virtual_alias_maps = ldap:/etc/postfix/ldap-forward-example.cf
#
# OR
#
#For local domains:
alias_maps = hash:/etc/mail/aliases,ldap:/etc/postfix/ldap-forward-example.cf

----------------------
That should be it. Hope this helps someone. I have been searching all over for this.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum