OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: [Fwd: ldap users & aliases config]

From: Wojtek Bogusz (WojtekFrontLineDefenders.org)
Date: Thu May 08 2008 - 12:12:25 CDT


thank you.

let me try hopefully more precise this time :-)

$ ldapsearch -b 'ou=EmailAliases,dc=frontline' -x
'(&(objectClass=inetOrgPerson)(sn=admin))' cn
# extended LDIF
#
# LDAPv3
# base <ou=EmailAliases,dc=frontline> with scope subtree
# filter: (&(objectClass=inetOrgPerson)(sn=admin))
# requesting: cn
#

# wojtek, EmailAliases, frontline
dn: cn=wojtek,ou=EmailAliases,dc=frontline

# john, EmailAliases, frontline
dn: cn=john,ou=EmailAliases,dc=frontline

# search result
search: 2
result: 0 Success

# numResponses: 3
# numEntries: 2

and:

$ sudo postmap -v -q adminfrontlinedefenders.org
ldap:/etc/postfix/ldap-aliases.cf
[... many lines here ...]
postmap: dict_ldap_lookup: /etc/postfix/ldap-aliases.cf: Searching with
filter (&(objectClass=inetOrgPerson)(sn=admin))
postmap: dict_ldap_get_values[1]: Search found 2 match(es)
postmap: dict_ldap_get_values[1]: Leaving dict_ldap_get_values
postmap: dict_ldap_lookup: Search returned nothing
postmap: dict_ldap_close: Closed connection handle for LDAP source
/etc/postfix/ldap-aliases.cf

so in ldapsearch:
- base: 'ou=EmailAliases,dc=frontline' with scope subtree
- filter: (&(objectClass=inetOrgPerson)(sn=admin))
- requesting: cn

in postmap -vq (also from the /etc/postfix/ldap-aliases.cf see below):
- base: 'ou=EmailAliases,dc=frontline' (see: 'search_base =
ou=EmailAliases,dc=frontline' below)
- filter: '(&(objectClass=inetOrgPerson)(sn=admin))'
- requesting: cn ('result_attribute = cn' below)

seems the same to me...

maybe i should setup some other 'result_filter' - now it is %s. and as i
can see in ldapsearch the result looks like this:
'cn=nikt,ou=EmailAliases,dc=frontline'. maybe i should define the
structure of this response for postfix-ldap? i do not know...

>>> You will rewrite "your-last-namegmail.com" to "your-accountgmail.com"
>>> even though the "gmail.com" address has nothing to do with you or your
>>> account.
>> does it mean that there is no other way than have all the accounts and
>> aliases repeating domain part ('frontlinedefenders.org')?
>
> No, you just need to make your rewriting rules apply *ONLY* to address in
> your domain. Failure to do that will yield unacceptable erratic results.

i am really sorry to be a bit slow here. but how do i do it? how would
you modify my confing to do this. see below:

$ postconf -n
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
mailbox_command = /usr/local/libexec/dovecot/deliver
mailbox_size_limit = 0
mydestination = frontlinedefeders.org, base.localhost, base, localhost
myhostname = base
mynetworks = 127.0.0.0/8,192.168.0.0/28
myorigin = "frontlinedefenders.org"
recipient_delimiter = +
relayhost = mail.localhost
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
virtual_alias_maps = ldap:/etc/postfix/ldap-aliases.cf, hash:/etc/aliases
virtual_gid_maps = static:33
virtual_mailbox_base = /home/vmail/domains
virtual_mailbox_domains = frontlinedefenders.org
virtual_mailbox_maps = ldap:/etc/postfix/ldap-accounts.cf
virtual_minimum_uid = 30000
virtual_transport = dovecot
virtual_uid_maps = static:30000

$ cat /etc/postfix/ldap-accounts.cf
server_host = localhost
search_base = ou=Users,dc=frontline
query_filter = (&(objectClass=posixAccount)(uid=%u))
result_attribute = uid
bind = no
version = 3

$ cat /etc/postfix/ldap-aliases.cf
server_host = localhost
search_base = ou=EmailAliases,dc=frontline
query_filter = (&(objectClass=inetOrgPerson)(sn=%u))
result_attribute = cn
bind = no
version = 3