Postfix, Dovecot und LDAP -> User not found

Debian macht sich hervorragend als Web- und Mailserver. Schau auch in den " Tipps und Tricks"-Bereich.
Antworten
RUDITERROR
Beiträge: 12
Registriert: 18.10.2019 10:51:21

Postfix, Dovecot und LDAP -> User not found

Beitrag von RUDITERROR » 14.06.2022 15:14:09

Hallo zusammen,

ich verzweifle gerade an dem Versuch, einen Mail-Server mit Dovecot, Postfix und LDAP einzurichten.

Ich erhalte beim Versuch, von extern eine E-Mail an meinen Mail-Server zu verschicken, folgende Fehlermeldung:

Code: Alles auswählen

Remote Server returned '< #5.1.1 X-Postfix; unknown user: "marco">'
Im Active-Directory habe ich einen User namens marco angelegt und im Atribut-Feld mail die E-Mail-Adresse (marco@firma.de) hinterlegt.

Was ich nicht verstehe ist, warum postfix den user "marco" als nicht gefunden meldet, obwohl ich doch in meinem LDAP-Filter als Rückgabewert die Mail-Adresse ausgeben lasse.

Ich bin für jeden Tipp, der mich weiter bringt, sehr dankbar, ich komme schon seit 2 Tagen keinen Meter vorwärts... :roll:

postfix - main.cf

Code: Alles auswählen

smtpd_banner = $myhostname ESMTP $mail_name
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
delay_warning_time = 4h

# TLS parameters
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.firma.de/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mail.firma.de/privkey.pem
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination

myhostname = mail.firma.de
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
dovecot_destination_recipient_limit = 1
#mailbox_command = /usr/lib/dovecot/deliver
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
#smtp_bind_address = your ip address (optional) ==>unmark and change the ip address for your setup.
smtpd_sasl_local_domain =
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
broken_sasl_auth_clients = yes
smtpd_tls_auth_only = no

smtp_use_tls = yes
smtp_tls_note_starttls_offer = yes
#smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom

home_mailbox = Maildir/

smtpd_recipient_restrictions =
    reject_unknown_client,
    reject_unauth_pipelining,
    reject_non_fqdn_sender,
    reject_non_fqdn_recipient,
    reject_unknown_sender_domain,
    reject_unknown_recipient_domain,
    reject_invalid_hostname,
    permit_mynetworks,
    reject_rbl_client zen.spamhaus.org,
    reject_rbl_client ix.dnsbl.manitu.net,
    reject_rbl_client bl.spamcop.net,
#    reject_unverified_recipient,
    reject_unauth_destination,
    permit

smtpd_data_restrictions =
    reject_unauth_pipelining,
    reject_multi_recipient_bounce,
    permit

smtpd_helo_required = yes

#transport_maps
maildrop_destination_concurrency_limit = 2
maildrop_destination_recipient_limit = 1
gnarwl_destination_concurrency_limit = 1
gnarwl_destination_recipient_limit = 1
#transport_maps = hash:/etc/postfix/transport_map
#transport_maps = hash:/etc/postfix/transport_map, ldap:/etc/postfix/ldap-transport.cf

mydestination = $transport_maps, localhost, localhost.localdomain, $myhostname, localhost.$mydomain, $mydomain

#virtual_alias_maps = ldap:/etc/postfix/ldap/ldap-aliases.cf
#    ldap:/etc/postfix/ldap/ldap-virtualforward.cf,
#    ldap:/etc/postfix/ldap/ldap-accountsmap.cf

# virtual accounts for delivery
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_mailbox_base = /var/mail/firma.de
virtual_mailbox_maps = ldap:/etc/postfix/ldap/ldap-accounts.cf
virtual_minimum_uid = 1000
virtual_uid_maps = static:1001
virtual_gid_maps = static:1001
local_recipient_maps = ldap:/etc/postfix/ldap/ldap-aliases.cf
Postfix - master.cf

Code: Alles auswählen

#
# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master" or
# on-line: http://www.postfix.org/master.5.html).
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (no)    (never) (100)
# ==========================================================================
smtp      inet  n       -       y       -       -       smtpd -v
#628       inet  n       -       y       -       -       qmqpd
pickup    unix  n       -       y       60      1       pickup
cleanup   unix  n       -       y       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
#qmgr     unix  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       y       1000?   1       tlsmgr
rewrite   unix  -       -       y       -       -       trivial-rewrite
bounce    unix  -       -       y       -       0       bounce
defer     unix  -       -       y       -       0       bounce
trace     unix  -       -       y       -       0       bounce
verify    unix  -       -       y       -       1       verify
flush     unix  n       -       y       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       y       -       -       smtp
relay     unix  -       -       y       -       -       smtp
        -o syslog_name=postfix/$service_name
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       y       -       -       showq
error     unix  -       -       y       -       -       error
retry     unix  -       -       y       -       -       error
discard   unix  -       -       y       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       y       -       -       lmtp
anvil     unix  -       -       y       -       1       anvil
scache    unix  -       -       y       -       1       scache
postlog   unix-dgram n  -       n       -       1       postlogd
...
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix  -       n       n       -       2       pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

dovecot   unix  -       n       n       -       -       pipe
         flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}
Postfix - ldap-accounts.cf, ldap-aliases.cf

Code: Alles auswählen

server_host = ldaps://172.16.10.10:636
server_port = 636
version = 3
bind = yes
start_tls = no
bind_dn = cn=user,ou=Benutzer,ou=Firma,dc=firmaintern,dc=net
bind_pw = 456
search_base = ou=Firma,dc=firmaintern,dc=net
scope = sub
query_filter = (&(mail=%s)(objectClass=person)(memberOf=cn=Mail,ou=Gruppen,ou=Firma,dc=firmaintern,dc=net))
result_attribute = mail
dovecot.conf

Code: Alles auswählen

auth_verbose = yes
mail_debug = yes
auth_debug = yes
base_dir = /var/run/dovecot/
#protocols = imap imaps pop3 pop3s lmtp
protocols = imap pop3 lmtp
protocol imap {
        mail_plugins = quota imap_quota
#       imap_client_workarounds=outlook-idle is no longer necessary
#       imap_client_workarounds = outlook-idle

}
protocol pop3 {
        mail_plugins = quota
        pop3_no_flag_updates = yes
        pop3_reuse_xuidl = no
        pop3_lock_session = no
        pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
}
protocol lda {
  mail_plugins = quota
  postmaster_address = admin@firma.de
  auth_socket_path = /var/run/dovecot/auth-master
  }

service lmtp {
 unix_listener /var/spool/postfix/private/dovecot-lmtp {
   mode = 0600
   user = postfix
   group = postfix
  }
}

plugin {
        quota = maildir
        quota_rule = Trash:storage=10%%
        quota_rule2 = Spam:storage=10%%
        quota_warning = storage=95%%/home/vmail/bin/quota-warning.sh 95
        quota_warning2 = storage=80%% /home/vmail/bin/quota-warning.sh 80
}
listen = *
shutdown_clients = yes
log_timestamp = "%b %d %H:%M:%S "
syslog_facility = mail
disable_plaintext_auth = no
ssl = no
ssl_cert = /etc/letsencrypt/live/mail.firma.de/fullchain.pem
ssl_key = /etc/letsencrypt/live/mail.firma.de/privkey.pem

login_chroot = yes
#login_chroot has been replaced by service { chroot }


#login_user = postfix
login_process_per_connection = yes
login_processes_count = 2
login_max_processes_count = 128
login_max_connections = 256
login_greeting = Welcome to Dovecot eMail Server.
login_log_format_elements = user=<%u> method=%m rip=%r lip=%l %c
login_log_format = %$: %s
#default_mail_env = maildir:/home/vmail/%d/%u
mail_location = maildir:/var/mail/firma.de/%u
first_valid_uid = 117 # REMEBER THIS MUST BE CHANGED TO YOUR UID FOR "postfix" FROM /etc/passwd
mail_uid = 1001
mail_gid = 1001
pop3_uidl_format = %08Xu%08Xv
auth default {
    mechanisms = PLAIN LOGIN
    passdb ldap {
        args = /etc/dovecot/dovecot-ldap.conf
    }
    userdb ldap {
        args = /etc/dovecot/dovecot-ldap.conf
    }
socket listen {
                master {
                        path = /var/run/dovecot/auth-master
                                mode = 0600
                        user = vmail
                        group = vmail
                }
                client {
                        path = /var/spool/postfix/private/auth
                        mode = 0660
                        user = postfix
                        group = postfix
                }
        }
        user = vmail
}
Postfix Debug-Log
NoPaste-Eintrag41722
Zuletzt geändert von RUDITERROR am 15.06.2022 08:31:36, insgesamt 1-mal geändert.

RUDITERROR
Beiträge: 12
Registriert: 18.10.2019 10:51:21

Re: Postfix, Dovecot und LDAP -> User not found

Beitrag von RUDITERROR » 14.06.2022 15:15:47

-
Zuletzt geändert von RUDITERROR am 15.06.2022 08:32:43, insgesamt 1-mal geändert.

RUDITERROR
Beiträge: 12
Registriert: 18.10.2019 10:51:21

Re: Postfix, Dovecot und LDAP -> User not found

Beitrag von RUDITERROR » 14.06.2022 15:16:51

-
Zuletzt geändert von RUDITERROR am 15.06.2022 08:32:58, insgesamt 1-mal geändert.

DeletedUserReAsG

Re: Postfix, Dovecot und LDAP -> User not found

Beitrag von DeletedUserReAsG » 14.06.2022 17:59:25

RUDITERROR hat geschrieben: ↑ zum Beitrag ↑
14.06.2022 15:16:51
(Sorry, die Anzahl der Zeichen ist in diesem Forum begrezt...)
Absichtlich:
Wichtiger Hinweis
Bevor Du einen Beitrag postest:

----
[…]
- Lange Codezeilen/Logs gehören nach NoPaste, in Deinen Beitrag dann der passende Link dazu.
Du könntest es nun beheben, und so die Wahrscheinlichkeit für Unterstützung um geschätzt ein bis zwei Größenordnungen erhöhen.

Nicht viele Leute haben Mausräder mit Freilauf …

Benutzeravatar
oln
Beiträge: 483
Registriert: 05.01.2021 09:41:24

Re: Postfix, Dovecot und LDAP -> User not found

Beitrag von oln » 15.06.2022 08:05:14

Moin,
bist du sicher, dass deine SearchBase stimmt?
Erwartet hätte ich sowas wie ou=users,dc=domain,dc=de.
Wie sieht denn dein LDAP-Tree aus?
Gruß Ole
AbuseIPDB

RUDITERROR
Beiträge: 12
Registriert: 18.10.2019 10:51:21

Re: Postfix, Dovecot und LDAP -> User not found

Beitrag von RUDITERROR » 15.06.2022 08:45:18

@niemand,
entschuldige bitte, wer lesen kann ist klar im Vorteil... :hail:

@oln, danke für deine Rückmeldung
meine Domäne heißt firma.de, in der 2 OU ' eingerichtet wurden (Firma -> Benutzer)
Mit dem Eintrag "scope = sub" in den LDAP-Files bestimme ich, dass die Unterordner durchsucht werden.

Bei einer Testabfrage mit der Ziel-E-Mail-Adresse "marco@firma.de" wird auch ein Eintrag gefunden und das Atribut "mail" zurückgeliefert:

postmap -vq marco@firma.de ldap:/etc/postfix/ldap/ldap-accounts.cf

Code: Alles auswählen

postmap: name_mask: all
postmap: inet_addr_local: configured 2 IPv4 addresses
postmap: inet_addr_local: configured 2 IPv6 addresses
postmap: dict_ldap_open: Using LDAP source /etc/postfix/ldap/ldap-accounts.cf
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: server_host = ldaps://172.16.10.10:636
postmap: cfg_get_int: /etc/postfix/ldap/ldap-accounts.cf: server_port = 636
postmap: cfg_get_int: /etc/postfix/ldap/ldap-accounts.cf: version = 3
postmap: dict_ldap_open: /etc/postfix/ldap/ldap-accounts.cf server_host URL is ldaps://172.16.10.10:636
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: scope = sub
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: search_base = ou=Firma,dc=firmaintern,dc=net
postmap: cfg_get_int: /etc/postfix/ldap/ldap-accounts.cf: timeout = 10
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: query_filter = (&(mail=%s)(objectClass=person)(memberOf=cn=Mail,ou=Gruppen,ou=Firma,dc=firmaintern,dc=net))
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: result_format = <NULL>
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: result_filter = %s
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: domain =
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: terminal_result_attribute =
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: leaf_result_attribute =
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: result_attribute = mail
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: special_result_attribute =
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: bind = yes
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: bind_dn = cn=user,ou=Benutzer,ou=Firma,dc=firmaintern,dc=net
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: bind_pw = 12345678
postmap: cfg_get_bool: /etc/postfix/ldap/ldap-accounts.cf: cache = off
postmap: cfg_get_int: /etc/postfix/ldap/ldap-accounts.cf: cache_expiry = -1
postmap: cfg_get_int: /etc/postfix/ldap/ldap-accounts.cf: cache_size = -1
postmap: cfg_get_int: /etc/postfix/ldap/ldap-accounts.cf: recursion_limit = 1000
postmap: cfg_get_int: /etc/postfix/ldap/ldap-accounts.cf: expansion_limit = 0
postmap: cfg_get_int: /etc/postfix/ldap/ldap-accounts.cf: size_limit = 0
postmap: cfg_get_int: /etc/postfix/ldap/ldap-accounts.cf: dereference = 0
postmap: cfg_get_bool: /etc/postfix/ldap/ldap-accounts.cf: chase_referrals = off
postmap: cfg_get_bool: /etc/postfix/ldap/ldap-accounts.cf: start_tls = off
postmap: cfg_get_bool: /etc/postfix/ldap/ldap-accounts.cf: tls_require_cert = off
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: tls_ca_cert_file =
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: tls_ca_cert_dir =
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: tls_cert =
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: tls_key =
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: tls_random_file =
postmap: cfg_get_str: /etc/postfix/ldap/ldap-accounts.cf: tls_cipher_suite =
postmap: cfg_get_int: /etc/postfix/ldap/ldap-accounts.cf: debuglevel = 0
postmap: dict_open: ldap:/etc/postfix/ldap/ldap-accounts.cf
postmap: dict_ldap_lookup: In dict_ldap_lookup
postmap: dict_ldap_lookup: No existing connection for LDAP source /etc/postfix/ldap/ldap-accounts.cf, reopening
postmap: dict_ldap_connect: Connecting to server ldaps://172.16.10.10:636
postmap: dict_ldap_connect: Actual Protocol version used is 3.
postmap: dict_ldap_connect: Binding to server ldaps://172.16.10.10:636 with dn cn=user,ou=Benutzer,ou=Firma,dc=firmaintern,dc=net
postmap: dict_ldap_connect: Successful bind to server ldaps://172.16.10.10:636 with dn cn=user,ou=Benutzer,ou=Firma,dc=firmaintern,dc=net
postmap: dict_ldap_connect: Cached connection handle for LDAP source /etc/postfix/ldap/ldap-accounts.cf
postmap: dict_ldap_lookup: /etc/postfix/ldap/ldap-accounts.cf: Searching with filter (&(mail=marco@firma.de)(objectClass=person)(memberOf=cn=Mail,ou=Gruppen,ou=Firma,dc=firmaintern,dc=net))
[b]postmap: dict_ldap_get_values[1]: Search found 1 match(es)
postmap: dict_ldap_get_values[1]: search returned 1 value(s) for requested result attribute mail
postmap: dict_ldap_get_values[1]: Leaving dict_ldap_get_values
postmap: dict_ldap_lookup: Search returned marco@firma.de
marco@firma.de[/b]
postmap: dict_ldap_close: Closed connection handle for LDAP source /etc/postfix/ldap/ldap-accounts.cf
Zuletzt geändert von RUDITERROR am 15.06.2022 14:07:47, insgesamt 1-mal geändert.

Benutzeravatar
oln
Beiträge: 483
Registriert: 05.01.2021 09:41:24

Re: Postfix, Dovecot und LDAP -> User not found

Beitrag von oln » 15.06.2022 09:36:21

Bei virtual_mailbox_maps möchtest du doch den Pfad der Mailbox zurück bekommen oder?
Mich hat schon gewundert, das du dort die gleiche Datei nimmst.
Für die Mailbox fehlt doch noch ein result_format oder?
Gruß Ole
AbuseIPDB

RUDITERROR
Beiträge: 12
Registriert: 18.10.2019 10:51:21

Re: Postfix, Dovecot und LDAP -> User not found

Beitrag von RUDITERROR » 15.06.2022 14:06:35

Ja, der Dateiname ist schon Irreführend...
Ich habe es mal mit dem Parameter result_format = %u versucht, leider ohne Erfolg.

Mein Basis-Verzeichnis bestimme ich doch mit diesem Parameter?:

Code: Alles auswählen

virtual_mailbox_base = /var/mail/firma.de
Der Zweite Parameter legt den Benutzer-Ordner fest, richtig?:

Code: Alles auswählen

virtual_mailbox_maps = ldap:/etc/postfix/ldap/ldap-accounts.cf
Durch das Ändern des Parameters result_format auf %u sollte die Änderung doch richtig sein, oder?

Code: Alles auswählen

root@Servername:/etc/postfix# postmap -q  marco@firma.de ldap:/etc/postfix/ldap/ldap-accounts.cf
marco
root@Servername:/etc/postfix# ls -alh /var/mail/firma.de/
insgesamt 12K
drwxr-sr-x 3 vmail vmail 4,0K Jun  1 08:15 .
drwxrwsr-x 3 root  mail  4,0K Jun  1 07:58 ..
drwx--S--- 6 vmail vmail 4,0K Jun  3 09:06 marco

Code: Alles auswählen

server_host = ldaps://172.16.10.10:636
server_port = 636
version = 3
bind = yes
start_tls = no
bind_dn = cn=user,ou=Benutzer,ou=Firma,dc=firmaintern,dc=net
bind_pw = 456
search_base = ou=Firma,dc=firmaintern,dc=net
scope = sub
query_filter = (&(mail=%s)(objectClass=person)(memberOf=cn=Mail,ou=Gruppen,ou=Firma,dc=firmaintern,dc=net))
result_format = %u
result_attribute = mail

Benutzeravatar
oln
Beiträge: 483
Registriert: 05.01.2021 09:41:24

Re: Postfix, Dovecot und LDAP -> User not found

Beitrag von oln » 15.06.2022 15:40:37

Ich habe hier ein etwas anderes Setup. Bei mir wirnd in den Home-Folder von dem jeweiligen User gespeichert. Weiterhin habe ich hier eine Active Directory mit Samba4.
Da gebe ich in virtual_mailbox_maps folgendes an: result_format = %d/%u/.Maildir/ Aber das tut glaube nichts zur Sache.

PS: DNS ist in Ordnung?

Code: Alles auswählen

dig domain.com MX
Gruß Ole
AbuseIPDB

RUDITERROR
Beiträge: 12
Registriert: 18.10.2019 10:51:21

Re: Postfix, Dovecot und LDAP -> User not found

Beitrag von RUDITERROR » 15.06.2022 18:46:47

Hi,

das trifft sich aber gut! :wink:

Ich nutze als AD auch Samba 4. Hast du in deinem Samba extra Attribute hinzugefügt, oder kommst du mit den Standard-Attributen aus (das ist mein Ziel). Hast du eine gute Anleitung? Ich hatte nur Anleitungen zum Einrichten mit openLDAP gefunden...

DNS sieht gut aus:

Code: Alles auswählen

root@Servername:/etc/postfix# dig mail.firma.de

; <<>> DiG 9.11.5-P4-5.1+deb10u7-Debian <<>> mail.firma.de
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2754
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: b586b0cb02ecac360100000062aa0a64259b9aa695daa429 (good)
;; QUESTION SECTION:
;mail.firma.de.        IN      A

;; ANSWER SECTION:
mail.firma.de. 600 IN  A       102.2.1.2.3

;; Query time: 16 msec
;; SERVER: 172.10.10.10#53(172.31.244.10)
;; WHEN: Mi Jun 15 18:35:48 CEST 2022
;; MSG SIZE  rcvd: 103
Auch die postmap-Testabfragen sehen gut aus:

Code: Alles auswählen

root@Servername:/etc/postfix# postmap -q marco@firma.de ldap:/etc/postfix/ldap/ldap-aliases.cf
marco@firma.de
root@Servername:/etc/postfix# postmap -q marco@firma.de ldap:/etc/postfix/ldap/ldap-accounts.cf
marco/.Maildir/
root@Servername:/etc/postfix#

Code: Alles auswählen

root@Servername:/etc/postfix# less /var/log/mail.log | grep maps_find
Jun 15 18:10:01 Servername postfix/smtpd[14309]: maps_find: recipient_canonical_maps: marco@firma		.de: not found
Jun 15 18:10:01 Servername postfix/smtpd[14309]: maps_find: recipient_canonical_maps: marco: not found
Jun 15 18:10:01 Servername postfix/smtpd[14309]: maps_find: recipient_canonical_maps: @firma.de: not found
Jun 15 18:10:01 Servername postfix/smtpd[14309]: maps_find: canonical_maps: marco@firma.de: not found
Jun 15 18:10:01 Servername postfix/smtpd[14309]: maps_find: canonical_maps: marco: not found
Jun 15 18:10:01 Servername postfix/smtpd[14309]: maps_find: canonical_maps: @firma.de: not found
Jun 15 18:10:01 Servername postfix/smtpd[14309]: maps_find: virtual_alias_maps: marco@firma.de: not found
Jun 15 18:10:01 Servername postfix/smtpd[14309]: maps_find: virtual_alias_maps: marco: not found
Jun 15 18:10:01 Servername postfix/smtpd[14309]: maps_find: virtual_alias_maps: @firma.de: not found
Jun 15 18:10:01 Servername postfix/smtpd[14309]: maps_find: local_recipient_maps: ldap:/etc/postfix/ldap/ldap-aliases.cf(0,lock|fold_fix|utf8_request): marco@firma.de = marco@firma.de
Ich glaube, hier liegt das Problem, der Eintrag local_recipient_maps ist, glaube ich, in der main.cf falsch konfiguriert, ich habe den Eintrag mal dahingehend geändert:

Code: Alles auswählen

...
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_mailbox_base = /var/mail/firma
virtual_mailbox_maps = ldap:/etc/postfix/ldap/ldap-accounts.cf
virtual_minimum_uid = 1000
virtual_uid_maps = static:1001
virtual_gid_maps = static:1001
#local_recipient_maps = ldap:/etc/postfix/ldap/ldap-aliases.cf
local_recipient_maps = $alias_maps
Ist in deiner Config den Paramter virtual_alias_maps gesetzt?
Zuletzt geändert von RUDITERROR am 16.06.2022 13:07:21, insgesamt 1-mal geändert.

RUDITERROR
Beiträge: 12
Registriert: 18.10.2019 10:51:21

Re: Postfix, Dovecot und LDAP -> User not found

Beitrag von RUDITERROR » 15.06.2022 19:58:35

kleiner Nachtrag, mit dem Parameter virtual_alias_maps funktioniert es auch nicht...

root@Servername:/etc/postfix# journalctl -f | grep maps_find
Jun 15 19:45:10 Servername postfix/smtpd[15479]: maps_find: recipient_canonical_maps: marco@firma: not found
Jun 15 19:45:10 Servername postfix/smtpd[15479]: maps_find: recipient_canonical_maps: marco: not found
Jun 15 19:45:10 Servername postfix/smtpd[15479]: maps_find: recipient_canonical_maps: @firma: not found
Jun 15 19:45:10 Servername postfix/smtpd[15479]: maps_find: canonical_maps: marco@firma: not found
Jun 15 19:45:10 Servername postfix/smtpd[15479]: maps_find: canonical_maps: marco: not found
Jun 15 19:45:10 Servername postfix/smtpd[15479]: maps_find: canonical_maps: @firma: not found
Jun 15 19:45:10 Servername postfix/smtpd[15479]: maps_find: virtual_alias_maps: ldap:/etc/postfix/ldap/ldap-aliases.cf(0,lock|fold_fix|utf8_request): marco@firma = marco@firma

In der Bounce-Mail steht dann

Code: Alles auswählen

Remote Server returned '< #5.1.1 X-Postfix; unknown user: "marco">'

Benutzeravatar
oln
Beiträge: 483
Registriert: 05.01.2021 09:41:24

Re: Postfix, Dovecot und LDAP -> User not found

Beitrag von oln » 16.06.2022 07:21:37

Moin
RUDITERROR hat geschrieben: ↑ zum Beitrag ↑
15.06.2022 18:46:47
Ich nutze als AD auch Samba 4. Hast du in deinem Samba extra Attribute hinzugefügt, oder kommst du mit den Standard-Attributen aus (das ist mein Ziel). Hast du eine gute Anleitung? Ich hatte nur Anleitungen zum Einrichten mit openLDAP gefunden...
Ich habe keine Attribute hinzu gefügt.
Postfix verbindet sich immer über LDAP. Ich finde diese Anleitung ganz gut.
RUDITERROR hat geschrieben: ↑ zum Beitrag ↑
15.06.2022 18:46:47
DNS sieht gut aus:

Code: Alles auswählen

root@Servername:/etc/postfix# dig mail.firma.de

; <<>> DiG 9.11.5-P4-5.1+deb10u7-Debian <<>> mail.firma.de
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2754
....
Diese Anfrage wollte ich nicht wissen. Gibt es einen MX auf firma.de(siehe Oben).
RUDITERROR hat geschrieben: ↑ zum Beitrag ↑
15.06.2022 18:46:47
Ist in deiner Config den Paramter virtual_alias_maps gesetzt?
Ja.
Mein Setup sieht fast gleich aus wie in der Anleitung.

Grundsätzliche Frage: Geht senden oder geht überhaupt schon etwas?
Gruß Ole
AbuseIPDB

RUDITERROR
Beiträge: 12
Registriert: 18.10.2019 10:51:21

Re: Postfix, Dovecot und LDAP -> User not found

Beitrag von RUDITERROR » 16.06.2022 13:06:28

Hi,

erst einmal vielen Dank für deine vielen Tipps! Mit deiner Anleitung hat es nun funktioniert. Das Problem lag an dem Parameter virtual_mailbox_maps. Ich habe im Grunde den Parameter virtual_mailbox_base auskommentiert und in der ad_virtual_mailbox_maps.cf den vollständigen Pfad zum Mail-Verzeichnis angegeben. Außerdem habe ich in der local_recipient_maps auf die virtual_mailbox_maps verwiesen.

VIELEN DANK nochmal! Ich habe jetzt zwar noch ein bisschen Arbeit vor mir, aber der Knoten ist nun hoffentlich geplatzt,,, :hail:

Für alle Interessierten, hier meine Config:

Code: Alles auswählen

biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
delay_warning_time = 4h

# TLS parameters
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.firma.de/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mail.firma.de/privkey.pem
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination

myhostname = mail.firma.de
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
dovecot_destination_recipient_limit = 1
mailbox_command = /usr/lib/dovecot/deliver
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
smtpd_sasl_local_domain = firma.de
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
broken_sasl_auth_clients = yes
smtpd_tls_auth_only = no

smtp_use_tls = yes
smtp_tls_note_starttls_offer = yes
#smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom

smtpd_sender_login_maps = ldap:/etc/postfix/ad_sender_login_maps.cf

home_mailbox = Maildir/

smtpd_recipient_restrictions =
    reject_unknown_client,
    reject_unauth_pipelining,
    reject_non_fqdn_sender,
    reject_non_fqdn_recipient,
    reject_unknown_sender_domain,
    reject_unknown_recipient_domain,
    reject_invalid_hostname,
    permit_mynetworks,
    reject_rbl_client zen.spamhaus.org,
    reject_rbl_client ix.dnsbl.manitu.net,
    reject_rbl_client bl.spamcop.net,
    reject_unverified_recipient,
    reject_unauth_destination,
    permit

smtpd_data_restrictions =
    reject_unauth_pipelining,
    reject_multi_recipient_bounce,
    permit

smtpd_helo_required = yes

#transport_maps
maildrop_destination_concurrency_limit = 2
maildrop_destination_recipient_limit = 1
gnarwl_destination_concurrency_limit = 1
gnarwl_destination_recipient_limit = 1
transport_maps = hash:/etc/postfix/transport_map

mydestination = $transport_maps, localhost, localhost.localdomain, $myhostname, localhost.$mydomain, $mydomain

# virtual accounts for delivery
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_mailbox_domains = firma.de
#virtual_mailbox_base = /var/mail/firma.de
virtual_mailbox_maps = ldap:/etc/postfix/ldap/ad_virtual_mailbox_maps.cf
virtual_alias_maps = ldap:/etc/postfix/ldap/ad_virtual_group_maps.cf
virtual_minimum_uid = 1000
virtual_uid_maps = static:1001
virtual_gid_maps = static:1001

local_recipient_maps = $alias_maps, $virtual_mailbox_maps
ad_sender_login_maps.cf

Code: Alles auswählen

server_host = ldaps://172.10.10.10:636
server_port = 636
version = 3
bind = yes
start_tls = no
bind_dn = cn=Benutzer,ou=Benutzer,ou=FIRMA,dc=firmaintern,dc=net
bind_pw = 123456
search_base = ou=FIRMA,dc=firmaintern,dc=net
scope = sub
query_filter = (&(mail=%s)(objectClass=person)(memberOf=cn=Mail,ou=Gruppen,ou=FIRMA,dc=firmaintern,dc=net))
result_attribute = mail
ad_virtual_mailbox_maps.cf

Code: Alles auswählen

server_host = ldaps://172.10.10.10:636
server_port = 636
version = 3
bind = yes
start_tls = no
bind_dn = cn=Benutzer,ou=Benutzer,ou=FIRMA,dc=firmaintern,dc=net
bind_pw = 123456
search_base = ou=FIRMA,dc=firmaintern,dc=net
scope = sub
query_filter = (&(mail=%s)(objectClass=person)(memberOf=cn=Mail,ou=Gruppen,ou=FIRMA,dc=firmaintern,dc=net))
result_format = /var/mail/firma.de/%u/
result_attribute = mail
ad_virtual_group_maps.cf

Code: Alles auswählen

server_host = ldaps://172.10.10.10:636
server_port = 636
version = 3
bind = yes
start_tls = no
bind_dn = cn=Benutzer,ou=Benutzer,ou=FIRMA,dc=firmaintern,dc=net
bind_pw = 123456
search_base = ou=FIRMA,dc=firmaintern,dc=net
scope = sub
query_filter    = (&(objectClass=group)(mail=%s))
special_result_attribute = member
leaf_result_attribute = mail
result_attribute= mail

Benutzeravatar
oln
Beiträge: 483
Registriert: 05.01.2021 09:41:24

Re: Postfix, Dovecot und LDAP -> User not found

Beitrag von oln » 16.06.2022 13:37:24

RUDITERROR hat geschrieben: ↑ zum Beitrag ↑
16.06.2022 13:06:28
Das Problem lag an dem Parameter virtual_mailbox_maps. Ich habe im Grunde den Parameter virtual_mailbox_base auskommentiert und in der ad_virtual_mailbox_maps.cf den vollständigen Pfad zum Mail-Verzeichnis angegeben. Außerdem habe ich in der local_recipient_maps auf die virtual_mailbox_maps verwiesen.
Hatte ich doch schon vorher geschrieben, dass du den Pfad als Result haben möchtest. :facepalm:
Gruß Ole
AbuseIPDB

Antworten