Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems trying to get LDAP lookup to work

Status
Not open for further replies.

murdo

Programmer
Oct 8, 2003
2
GB
Hi,

Can anybody help me with this... I'm having problems trying to implement ldap dir lookups in postfix. I've been stuck with this for a number of hours now and any help would be greatly appreciated

Many Thanks
Murdo

If i run ldapsearch -x -LLL -b "ou=people,dc=example.com,o=hosting,dc=pabby" "(mail=me@example.com)"
or ldapsearch -x -LLL -b "o=hosting,dc=pabby" "(mail=me@example.com)" it correctly retruns following

dn: uid=me@example.com,ou=people,dc=example.com,o=hosting,dc=pabby
uidNumber: 1011
uid: me@example.com
objectClass: CourierMailAccount
objectClass: CourierMailAlias
objectClass: mozillaOrgPerson
objectClass: inetOrgPerson
mozillaHomeState: My State
cn: Mini Me
sn: Me
givenName: Mini
mail: me@example.com
postalAddress: Some Street
postalCode: SW19 5AE
st: Some Province
mobile: 777 777 777
homePhone: 777 777 777
mailbox: /home/email/domains/example.com/me/Maildir
maildrop: mini.me@example.com
mozillaSecondEmail: mini.me@example2.com
userPassword:: cXdlcnR5
homeDirectory: /home/email/domains/example.com/me

but when I try to implement this ldap lookup in postifix i get an "Invald DN error".

This is the shortened debug output from the postmap command
#------------POSTMAP DEBUG OUTPUT
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: server_host = 127.0.0.1
postmap: cfg_get_int: /etc/postfix/ldap/local_recipients.cf: server_port = 389
postmap: cfg_get_int: /etc/postfix/ldap/local_recipients.cf: version = 3
postmap: dict_ldap_open: /etc/postfix/ldap/local_recipients.cf server_host URL is ldap://127.0.0.1:389
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: scope = sub
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: search_base = "o=hosting,dc=pabby"
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: domain =
postmap: cfg_get_int: /etc/postfix/ldap/local_recipients.cf: timeout = 10
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: query_filter = (mail=%s)
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: result_format = <NULL>
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: result_filter = %s
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: result_attribute = uid
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: special_result_attribute =
postmap: cfg_get_bool: /etc/postfix/ldap/local_recipients.cf: bind = on
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: bind_dn = cn=Manager,dc=pabby
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: bind_pw = qwerty
postmap: cfg_get_bool: /etc/postfix/ldap/local_recipients.cf: cache = off
postmap: cfg_get_int: /etc/postfix/ldap/local_recipients.cf: cache_expiry = -1
postmap: cfg_get_int: /etc/postfix/ldap/local_recipients.cf: cache_size = -1
postmap: cfg_get_int: /etc/postfix/ldap/local_recipients.cf: recursion_limit = 1000
postmap: cfg_get_int: /etc/postfix/ldap/local_recipients.cf: expansion_limit = 0
postmap: cfg_get_int: /etc/postfix/ldap/local_recipients.cf: size_limit = 0
postmap: cfg_get_int: /etc/postfix/ldap/local_recipients.cf: dereference = 0
postmap: cfg_get_bool: /etc/postfix/ldap/local_recipients.cf: chase_referrals = off
postmap: cfg_get_bool: /etc/postfix/ldap/local_recipients.cf: start_tls = off
postmap: cfg_get_bool: /etc/postfix/ldap/local_recipients.cf: tls_require_cert = off
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: tls_ca_cert_file =
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: tls_ca_cert_dir =
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: tls_cert =
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: tls_key =
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: tls_random_file =
postmap: cfg_get_str: /etc/postfix/ldap/local_recipients.cf: tls_cipher_suite =
postmap: cfg_get_int: /etc/postfix/ldap/local_recipients.cf: debuglevel = 2
postmap: dict_open: ldap:/etc/postfix/ldap/local_recipients.cf
postmap: dict_ldap_lookup: In dict_ldap_lookup
postmap: dict_ldap_lookup: No existing connection for LDAP source /etc/postfix/ldap/local_recipients.cf, reopening
postmap: dict_ldap_connect: Connecting to server ldap://127.0.0.1:389
postmap: dict_ldap_connect: Actual Protocol version used is 3.
postmap: dict_ldap_connect: Binding to server ldap://127.0.0.1:389 as dn cn=Manager,dc=pabby
postmap: dict_ldap_debug: 0000: 30 25 02 01 01 60 20 02 01 03 04 13 63 6e 3d 4d 0%...` .....cn=M
postmap: dict_ldap_debug: 0010: 61 6e 61 67 65 72 2c 64 63 3d 70 61 62 62 79 80 anager,dc=pabby.
postmap: dict_ldap_debug: 0020: 06 71 77 65 72 74 79 .qwerty
postmap: dict_ldap_debug: ldap_write: want=39, written=39
postmap: dict_ldap_debug: 0000: 30 25 02 01 01 60 20 02 01 03 04 13 63 6e 3d 4d 0%...` .....cn=M
postmap: dict_ldap_debug: 0010: 61 6e 61 67 65 72 2c 64 63 3d 70 61 62 62 79 80 anager,dc=pabby.
postmap: dict_ldap_debug: 0020: 06 71 77 65 72 74 79 .qwerty
postmap: dict_ldap_debug: ldap_read: want=8, got=8
postmap: dict_ldap_debug: 0000: 30 0c 02 01 01 61 07 0a 0....a..
postmap: dict_ldap_debug: ldap_read: want=6, got=6
postmap: dict_ldap_debug: 0000: 01 00 04 00 04 00 ......
postmap: dict_ldap_debug: request done: ld 0x81b9e0b8 msgid 1
postmap: dict_ldap_connect: Successful bind to server ldap://127.0.0.1:389 as cn=Manager,dc=pabby
postmap: dict_ldap_connect: Cached connection handle for LDAP source /etc/postfix/ldap/local_recipients.cf
postmap: dict_ldap_lookup: /etc/postfix/ldap/local_recipients.cf: Searching with filter (mail=me@example.com)
postmap: dict_ldap_debug: 0000: 30 49 02 01 02 63 44 04 14 22 6f 3d 68 6f 73 74 0I...cD.."o=host
postmap: dict_ldap_debug: 0010: 69 6e 67 2c 64 63 3d 70 61 62 62 79 22 0a 01 02 ing,dc=pabby"...
postmap: dict_ldap_debug: 0020: 0a 01 00 02 01 00 02 01 00 01 01 00 a3 16 04 04 ................
postmap: dict_ldap_debug: 0030: 6d 61 69 6c 04 0e 6d 65 40 65 78 61 6d 70 6c 65 mail..me@example
postmap: dict_ldap_debug: 0040: 2e 63 6f 6d 30 05 04 03 75 69 64 .com0...uid
postmap: dict_ldap_debug: ldap_write: want=75, written=75
postmap: dict_ldap_debug: 0000: 30 49 02 01 02 63 44 04 14 22 6f 3d 68 6f 73 74 0I...cD.."o=host
postmap: dict_ldap_debug: 0010: 69 6e 67 2c 64 63 3d 70 61 62 62 79 22 0a 01 02 ing,dc=pabby"...
postmap: dict_ldap_debug: 0020: 0a 01 00 02 01 00 02 01 00 01 01 00 a3 16 04 04 ................
postmap: dict_ldap_debug: 0030: 6d 61 69 6c 04 0e 6d 65 40 65 78 61 6d 70 6c 65 mail..me@example
postmap: dict_ldap_debug: 0040: 2e 63 6f 6d 30 05 04 03 75 69 64 .com0...uid
postmap: dict_ldap_debug: ldap_read: want=8, got=8
postmap: dict_ldap_debug: 0000: 30 16 02 01 02 65 11 0a 0....e..
postmap: dict_ldap_debug: ldap_read: want=16, got=16
postmap: dict_ldap_debug: 0000: 01 22 04 00 04 0a 69 6e 76 61 6c 69 64 20 44 4e ."....invalid DN
postmap: dict_ldap_debug: request done: ld 0x81b9e0b8 msgid 2
postmap: warning: dict_ldap_lookup: Search error 34: Invalid DN syntax
postmap: dict_ldap_debug: 0000: 30 05 02 01 03 42 00 0....B.
postmap: dict_ldap_debug: ldap_write: want=7, written=7
postmap: dict_ldap_debug: 0000: 30 05 02 01 03 42 00 0....B.
#-------END OF DEBUG OUTPUT--------------------------


local_recipient_maps = ldap:/etc/postfix/ldap/local_recipients.cf
virtual_alias_maps = proxy:ldap:/etc/postfix/ldap/virtual_aliases.cf

this is the contents of the postifx ldap config files
#--------local_recipeints.cf---------
version=3
server_host = 127.0.0.1
bind = yes
bind_dn = cn=Manager,dc=pabby
bind_pw = qwerty

search_base = "o=hosting,dc=pabby"
query_filter = (mail=%s)

result_attribute = uid
debuglevel = 2
#-----------------------


#-------virtual_aliases.cf----------------
bind = no
server_host = ldap://localhost
search_base = "o=hosting,dc=pabby"
query_filter = (maildrop=%s)
result_attribute = mail
#-----------------------


This is my slapd.config

#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/nis.schema
include /etc/openldap/schema/authldap.schema
include /etc/openldap/schema/mozilla_addrbook.schema

# Allow LDAPv2 client connections. This is NOT the default.
allow bind_v2


pidfile /var/run/openldap/slapd.pid
argsfile /var/run/openldap/slapd.args

# Load dynamic backend modules:
# modulepath /usr/lib/openldap
# moduleload back_bdb.la
# moduleload back_ldap.la
# moduleload back_ldbm.la
# moduleload back_passwd.la
# moduleload back_shell.la


access to dn.subtree="o=hosting,dc=pabby" by * read


#######################################################################
# ldbm and/or bdb database definitions
#######################################################################

database ldbm
suffix "dc=pabby"
rootdn "cn=Manager,dc=pabby"
rootpw qwerty

# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
directory /var/lib/ldap

# Indices to maintain for this database
index objectClass pres,eq
index cn eq,sub
index mail,maildrop pres
index mailbox,quota,uidNumber,gidNumber eq


#--------- DUMP OF LDAP DIR -------------
dn: dc=pabby
objectClass: top
objectClass: domain
dc: pabby
structuralObjectClass: domain
entryUUID: 59448988-c0d2-102b-9168-1518e96aa1f1
creatorsName: cn=Manager,dc=pabby
createTimestamp: 20070707123554Z
entryCSN: 20070707123554Z#000000#00#000000
modifiersName: cn=Manager,dc=pabby
modifyTimestamp: 20070707123554Z

dn: cn=Manager,dc=pabby
objectClass: top
objectClass: organizationalRole
cn: Manager
structuralObjectClass: organizationalRole
entryUUID: 5945a642-c0d2-102b-9169-1518e96aa1f1
creatorsName: cn=Manager,dc=pabby
createTimestamp: 20070707123554Z
description: The root ldap user
entryCSN: 20070707162941Z#000000#00#000000
modifiersName: cn=Manager,dc=pabby
modifyTimestamp: 20070707162941Z

dn: o=hosting,dc=pabby
objectClass: top
objectClass: organization
o: hosting
structuralObjectClass: organization
entryUUID: 59466938-c0d2-102b-916a-1518e96aa1f1
creatorsName: cn=Manager,dc=pabby
createTimestamp: 20070707123554Z
description: The root node for hosted domains
entryCSN: 20070707163129Z#000000#00#000000
modifiersName: cn=Manager,dc=pabby
modifyTimestamp: 20070707163129Z


dn: dc=example.com,o=hosting,dc=pabby
dc: example.com
o: Example Domain
objectClass: dcObject
objectClass: organization
structuralObjectClass: organization
entryUUID: 252a64a4-c1a6-102b-97af-757f7cce9ef4
creatorsName: cn=Manager,dc=pabby
createTimestamp: 20070708135200Z
entryCSN: 20070708135200Z#000000#00#000000
modifiersName: cn=Manager,dc=pabby
modifyTimestamp: 20070708135200Z

dn: ou=people,dc=example.com,o=hosting,dc=pabby
ou: people
mail: me@example.com
objectClass: organizationalUnit
objectClass: CourierMailAlias
structuralObjectClass: organizationalUnit
entryUUID: 3449ab20-c1a6-102b-97b0-757f7cce9ef4
creatorsName: cn=Manager,dc=pabby
createTimestamp: 20070708135225Z
description: All Example Domain e-mail addresses
maildrop: all@example.com
entryCSN: 20070708135340Z#000000#00#000000
modifiersName: cn=Manager,dc=pabby
modifyTimestamp: 20070708135340Z

dn: uid=me@example.com,ou=people,dc=example.com,o=hosting,dc=pabby
uidNumber: 1011
uid: me@example.com
homeDirectory: /home/email/domains/example.com/me
objectClass: CourierMailAccount
objectClass: CourierMailAlias
objectClass: mozillaOrgPerson
objectClass: inetOrgPerson
mozillaHomeState: My State
structuralObjectClass: inetOrgPerson
entryUUID: a06cddae-c1a6-102b-97b3-757f7cce9ef4
creatorsName: cn=Manager,dc=pabby
createTimestamp: 20070708135527Z
cn: Mini Me
sn: Me
givenName: Mini
mail: me@example.com
postalAddress: Some Street
postalCode: SW19 5AE
st: Some Province
mobile: 777 777 777
homePhone: 777 777 777
mailbox: /home/email/domains/example.com/me/Maildir
maildrop: mini.me@example.com
mozillaSecondEmail: mini.me@example2.com
userPassword:: cXdlcnR5
entryCSN: 20070708140243Z#000000#00#000000
modifiersName: cn=Manager,dc=pabby
modifyTimestamp: 20070708140243Z

dn: uid=abc@example.com,ou=people,dc=example.com,o=hosting,dc=pabby
uidNumber: 1011
uid: abc@example.com
objectClass: CourierMailAccount
objectClass: CourierMailAlias
objectClass: mozillaOrgPerson
objectClass: inetOrgPerson
mozillaHomeState: Isle of Harris
gidNumber: 1011
structuralObjectClass: inetOrgPerson
entryUUID: b16e7644-c1a6-102b-97b4-757f7cce9ef4
creatorsName: cn=Manager,dc=pabby
createTimestamp: 20070708135555Z
cn: ABC DEF
sn: DEF
userPassword:: cXdlcnR5
givenName: ABC
mail: abc@example.com
postalAddress: Some Street
postalCode: SW19 5AE
st: My State
mobile: 555 555 555
homePhone: 555 555 555
mailbox: /home/email/domains/example.com/abc/Maildir
homeDirectory: /home/email/domains/example.com/abc
maildrop: abc.def@example.com
mozillaSecondEmail: abc@example2.com
entryCSN: 20070708140139Z#000000#00#000000
modifiersName: cn=Manager,dc=pabby
modifyTimestamp: 20070708140139Z
#--------------------------------------------

 
For future reference Victor Duchovni pointed out the problem with my LDAP lookup, all i had to do was lose the quotes in my search_base

search_base = o=hosting,dc=pabby OK

search_base = "o=hosting,dc=pabby" INVALID DN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top