Environment: CentOS 7.9, Sendmail 8.14, OpenLDAP 2.4
I'm trying to get sendmail to read its aliases from an LDAP database (this has worked with NIS for years, but NIS is fading into the twilight). My mail server is an LDAP client.
In mailserver:/etc/mail/sendmail.mc
:
define(confLDAP_DEFAULT_SPEC, `-H ldaps://ldap.myoffice.mycompany.org -b "ou=Aliases,dc=myoffice,dc=mycompany,dc=org" -d "uid=sendmail,dc=myoffice,dc=mycompany,dc=org" -M simple -P /etc/mail/secret')dnl
define(`ALIAS_FILE',`ldap:-k (&(objectClass=nisMailAlias)(cn=%0)) -v "rfc822MailMember",/etc/aliases')dnl
Deriving that first line was painful, since my web-fu was poor as I searched for documentation on the sendmail K macro for LDAP. This page was the best I could find, and it appears to be for an older version of sendmail.
When I restart sendmail on the mail server and try to use the aliases database, the response is:
# sendmail -bv sysadmin
ldap_init/ldap_bind failed to ldaps://ldap.myoffice.mycompany.org in map Alias0: Protocol error
sysadmin... deliverable: mailer local, user sysadmin
Note when I revert back to the NIS version, the alias resolves; this is the output I was expecting:
# sendmail -bv sysadmin
myname... deliverable: mailer local, user myname
In mailserver:/etc/openldap/ldap.conf
:
BASE dc=myoffice,dc=mycompany,dc=org
URI ldaps://ldap.myoffice.mycompany.org ldaps://ldap-replica-1.myoffice.mycompany.org ldaps://ldap-replica-2.myoffice.mycompany.org
SIZELIMIT unlimited
TLS_CACERT /etc/mail/certs/certs-latest/__myoffice_mycompany_org.cer
TLS_CACERTDIR /etc/mail/certs/certs/certs-latest
__myoffice_mycompany_org.cer
is in PEM format and contains the certificate chain and a wildcard certificate for my site, *.myoffice.mycompany.org
.
For authentication and searches outside of sendmail, the LDAP searches on via the mail server's LDAP client configuration appear to work just fine. Here are my tests, all of which produce the results I expect:
# Authentication-type searches
ldapsearch -LLL -x -H ldaps://ldap.myoffice.mycompany.org "(uid=myname)"
ldapsearch -LLL -x uid=myname -b dc=myoffice,dc=mycompany,dc=org
ldapsearch -LLL -x uid=myname
# Mail-aliase-type searches
ldapsearch -x -h ldap.myoffice.mycompany.org -b "ou=Aliases,dc=myoffice,dc=mycompany,dc=org" "cn=sysadmin"
ldapsearch -x -H ldaps://ldap.myoffice.mycompany.org -b "ou=Aliases,dc=myoffice,dc=mycompany,dc=org" "cn=sysadmin"
ldapsearch -H ldaps://ldap.myoffice.mycompany.org -b "ou=Aliases,dc=myoffice,dc=mycompany,dc=org" "(cn=sysadmin)" -D "uid=sendmail,dc=myoffice,dc=mycompany,dc=org" -y /etc/mail/secret
The output of the last three commands is identical, and demonstrates that I set up the aliases on the LDAP server according to misc.schema
:
# extended LDIF
#
# LDAPv3
# base <ou=Aliases,dc=myoffice,dc=mycompany,dc=org> with scope subtree
# filter: cn=sysadmin
# requesting: ALL
#
# sysadmin, Aliases, myoffice.mycompany.org
dn: cn=sysadmin,ou=Aliases,dc=myoffice,dc=mycompany,dc=org
cn: sysadmin
objectClass: nisMailAlias
objectClass: top
rfc822MailMember: myname
# search result
search: 2
result: 0 Success
# numResponses: 2
# numEntries: 1
Note that for the last ldapsearch
above, in order to try to debug what's going on, I created a separate user uid=sendmail,dc=myoffice,dc=mycompany,dc=org
on my LDAP server, with the clear-text password in /etc/mail/secret
.
In sendmail.mc
, I have also tried:
define(confLDAP_DEFAULT_SPEC, `-h ldap.myoffice.mycompany.org -b "ou=Aliases,dc=myoffice,dc=mycompany,dc=org"')dnl
define(confLDAP_DEFAULT_SPEC, `-H ldaps://ldap.myoffice.mycompany.org -b "ou=Aliases,dc=myoffice,dc=mycompany,dc=org"')dnl
but the results were the same.
Just to confirm that account myname
exists (though I doubt that's the issue):
# ldapsearch -LLL -x uid=myname -b dc=myoffice,dc=mycompany,dc=org
dn: uid=myname,ou=People,dc=myoffice,dc=mycompany,dc=org
uid: myname
cn: Bill Myname
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
shadowLastChange: 17316
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 11230
gidNumber: 10130
homeDirectory: /myoffice/desktop/home/myname
gecos: Bill Myname,Room 321,x2280
What am I missing? Or to put it another way, how are the LDAP lookups in sendmail different from LDAP lookups in the rest of CentOS?
Edit:
I found a web page that suggested that the problem might be that sendmail on CentOS 7 may use certificates in its NSS store instead of just the text files in the CERT_DIR
directory. I followed the directions suggested on that page:
cd /etc/openldap/certs
certutil -A -d . -n "Myoffice 2022" -a -i /etc/mail/certs/certs-latest/__myoffice_mycompany_org.cer -t "CT,c,"
But this made no changes in sendmail's LDAP+aliases behavior.