Avatar of brucepennypacker
brucepennypacker asked on

Configuring sendmail to perform LDAP address lookups

In a nutshell I need to set up a sendmail server (running on CentOS linux) that will look up recipient addresses via LDAP and I'm not having much luck.  From what I've read we need to configure sendmail to use LDAP and it looks like I want to use the genericstable for LDAP queries but it doesn't look like its working for me.

Here are the gory details:  We have an environment where we have a fairly large LDAP database of users and their primary e-mail addresses.  We have a high-performance research cluster (and a second one being planned) that these users can log into and submit jobs for processing.  Right now any e-mail generated as a result of those jobs is getting lost because sendmail was never configured properly.  We need to set up sendmail to do a lookup in LDAP to determine a users primary e-mail address and use that as the delivery address.

To summarize our LDAP configuration, a typical entry contains the following fields (assuming myself) in ObjectClass=fooPerson:
cn: Bruce Pennypacker
uid: bpennypa (my login name on the servers)
mail: bruce.pennypacker@... (my primary e-mail address)

Assume the base DN for our LDAP setup is "dc=foo,dc=bar"

I know that LDAP lookups work properly from this particular server.  I wrote a quick little perl script to verify that it can query the LDAP server and it's working properly.

The first thing I did was build a custom version of sendmail, enabling the LDAPMAP option.  This is showing up in the sendmail output when I use -d so I'm sure it was built properly.  I then added the following to my sendmail .mc file:

define(`confLDAP_DEFAULT_SPEC', `-p 389 -h ldap.foobar.com -b dc=foo,dc=bar')dnl
FEATURE(`genericstable', `ldap:-k (&(objectClass=fooPerson)(uid=%0)) -v mail')dnl

I rebuilt sendmail.cf after doing the above and see the following in that file:

# default LDAP map specification
# need to set this now before any LDAP maps are defined
O LDAPDefaultSpec=-p 389 -h ldap.foobar.com -b dc=foo,dc=bar

# LDAP routing maps
Kldapmh ldap -1 -T<TMPF> -v mailHost -k (&(objectClass=inetLocalMailRecipient)(mailLocalAddress=%0))

Kldapmra ldap -1 -T<TMPF> -v mailRoutingAddress -k (&(objectClass=inetLocalMailRecipient)(mailLocalAddress=%0))

# Generics table (mapping outgoing addresses)
Kgenerics ldap:-k (&(objectClass=fooPerson)(uid=%0)) -v mail

But if I run sendmail -d -bv bpennypa to see if it'll do a lookup and convert the name it doesn't work.  I end up with a "user unknown" error.  The debug output doesn't seem to indicate any LDAP query occurring.  So what am I missing?
DatabasesEmail ServersLinux

Avatar of undefined
Last Comment

8/22/2022 - Mon


Well that redhat link just shows how to enable ldap routing which isn't what I'm trying to do.  I'm trying to do ldap based address translation.  The first link pretty much covered everything I've already attempted without any luck.

I did finally figure this out on my own after a bit more testing.  I didn't want to be using the generics table but the aliases table.  Here's what I needed to make this work:

define(`confLDAP_DEFAULT_SPEC', `-p 389 -h `ldap.foobar.com' -b dc=`foo,dc=bar'')dnl
define(`ALIAS_FILE', `/etc/aliases,ldap:-k (&(objectClass=fooPerson)(uid=%0)) -v mail')dnl


Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck