User list from active directory for mail routing


I have a situation where I need two exchange servers from separate organisations to be able to recieve mail on the one domain name. I have figured that I would use a linux box of some flavour to run a script everytime mail was coming in to look up the username in the seperate domains, once it found the user in one of the domains it would forward that email to the appropriate exchange server, via SMTP.

So basically I just need a linux box sitting in front of the two exchange servers to seperate the mail. I would prefer to have two scripts, one to create a user list txt file by running a LDAP query on the AD's once a day and another to forward the mail by looking at that txt file. Im guessing I would need a mail server of some sort, exim maybe ? then configure its router to do the forwarding job.

Any suggestions would be greatly appreciated.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you could use sendmail and assign a catch-all entry in virtusertable, then in the catch-all account use procmail to do the LDAP search and forward to the appropriate mail server.
You could use a perl script to build an aliases or virtusertable map that forwards mail to the appropriate exchange server.
You can use postfix to do this. It can receive the mail and using virtusertables forward the mail to the appropriate boxes. The big advantage of postfix over sendmail in this case is that you can have postfix read LDAP information as the virtual user tables. So you can use information directly from the AD. no need for daily updates or cronjobs.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

sendmail can perform ldap searches for mail routing, too. however, usign a MTA that directly searches the LDAP server for figuring out who themail is directed too, means that all addreses in the current LDAP servers must be updated with another address for the new domain, besides how do you handle searching both LDAP servers with postfix and/or sendmail?

I don't have the manuals at hand, but I think that you can define some additional properties for a LDAP connection, you might even be able to abuse that into delivering the proper mail address, the data has to be in there already (at least in the dn). Also in postfix you can use multiple lookup-tables (as in sendmail- you can easily use more than 1 alias file).

This is not helping to answer the question though...
SinzzzzAuthor Commented:
Thanks for the suggestions guys. All was helpfull. I will start playing around with postfix and let you know how i Go.


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux OS Dev

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.