jeschero
Goto Top

Problem beim einrichten eines OpenLDAP Proxy für Active Directory

Guten Abend alle zusammen,

ich versuche gerade eine OpenLDAP Proxy für Active Directory aufzusetzen.

Er wird genötigt um Dockercontainer ohne Unterstützung für ldaps mit den Benutzerdaten zu versorgen.
Der OpenLDAP Proxy soll nachher per ldap nur in Docker erreichbar sein, ist nicht 100% sicher, aber für meine Zwecke reicht es.
Das AD ist nur per ldaps erreichbar.

Ich verwende noch eine Debian 10 VM um erstmal die Config korrekt einzustellen.
Ich habe mich an den folgenden Einträge gerichtet:
- https://doc.owncloud.com/server/admin_manual/configuration/ldap/ldap_pro ...
- https://wiki.samba.org/index.php/OpenLDAP_as_proxy_to_AD

Ich überprüfe mit "/usr/sbin/slaptest -f /etc/ldap/slapd.conf -F /etc/ldap/slapd.d/" meine Config und starte nach Änderung den Service "slapd" neu.

Die /etc/default/slapd habe ich um folgende Zeile angepasst:
SLAPD_CONF=/etc/ldap/slapd.conf


Meine /etc/ldap/lslapd.conf:
### Schema includes
###########################################################
include         /etc/ldap/schema/core.schema
include         /etc/ldap/schema/cosine.schema
include         /etc/ldap/schema/nis.schema
include         /etc/ldap/schema/inetorgperson.schema
include         /etc/ldap/schema/misc.schema
include         /etc/ldap/schema/microsoftattributetype.schema


## Module paths ##############################################################
modulepath      /usr/lib/ldap
moduleload      back_ldap
moduleload      rwm


# Main settings
###############################################################
pidfile         /var/run/slapd/slapd.pid
argsfile        /var/run/slapd/slapd.args

### Database definition (Proxy to AD)
#########################################

#backend         ldap

database        ldap
readonly        yes
protocol-version 3
rebind-as-user  yes
uri             "ldaps://hn-dc01.example.net:636"  
suffix          "DC=int,DC=example,DC=net"  
#chase-referrals yes
binddn          "CN=ldapsearch,CN=Users,DC=int,DC=example,DC=net"  
bindpw          "<password>"  
TLSCACertificateFile     /etc/ldap/certs/example-ADCA.crt


attributetype ( 1.2.840.113556.1.4.221
       NAME 'sAMAccountName'  
       SYNTAX '1.3.6.1.4.1.1466.115.121.1.15'  
       SINGLE-VALUE )

attributetype ( 1.2.840.113556.1.2.210
       NAME 'proxyAddresses'  
       SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' )  


overlay         rwm

# Now we rewrite the attributes
rwm-map         attribute uid sAMAccountName
rwm-map         attribute mail proxyAddresses
#rwm-map         attribute dn distinguishedName

### Logging
###################################################################
loglevel        any

Die /etc/ldap/ldap.conf:
#
# LDAP Defaults
#

# See ldap.conf(5) for details
# This file should be world readable but not world writable.

#BASE   dc=example,dc=com
#URI    ldap://ldap.example.com ldap://ldap-master.example.com:666

#SIZELIMIT      12
#TIMELIMIT      15
#DEREF          never

# TLS certificates (needed for GnuTLS)
#TLS_CACERT     /etc/ssl/certs/ca-certificates.crt
TLS_CACERT      /etc/ldap/certs/TecIn-ADCA.crt

Mit diesem Kommando teste ich lokal den Proxy:
ldapsearch -H ldap://localhost -x -LLL \
    -D "cn=ldapsearch,cn=Users,dc=int,dc=example,dc=net" \  
    -b "cn=Users,dc=int,dc=example,dc=net" \  
    -W name -d 5

Leider bekomme ich immer folgenden Fehler:
ldap_url_parse_ext(ldap://localhost)
ldap_create
ldap_url_parse_ext(ldap://localhost:389/??base)
ldap_sasl_bind
ldap_send_initial_request
ldap_new_connection 1 1 0
ldap_int_open_connection
ldap_connect_to_host: TCP localhost:389
ldap_new_socket: 3
ldap_prepare_socket: 3
ldap_connect_to_host: Trying ::1 389
ldap_pvt_connect: fd: 3 tm: -1 async: 0
attempting to connect:
connect success
ldap_open_defconn: successful
ldap_send_server_request
ber_scanf fmt ({it) ber:
ber_scanf fmt ({i) ber:
ber_flush2: 79 bytes to sd 3
ldap_result ld 0x56538d980580 msgid 1
wait4msg ld 0x56538d980580 msgid 1 (infinite timeout)
wait4msg continue ld 0x56538d980580 msgid 1 all 1
** ld 0x56538d980580 Connections:
* host: localhost  port: 389  (default)
  refcnt: 2  status: Connected
  last used: Sun Nov 17 21:18:22 2019


** ld 0x56538d980580 Outstanding Requests:
 * msgid 1,  origid 1, status InProgress
   outstanding referrals 0, parent count 0
  ld 0x56538d980580 request count 1 (abandoned 0)
** ld 0x56538d980580 Response Queue:
   Empty
  ld 0x56538d980580 response count 0
ldap_chkResponseList ld 0x56538d980580 msgid 1 all 1
ldap_chkResponseList returns ld 0x56538d980580 NULL
ldap_int_select
read1msg: ld 0x56538d980580 msgid 1 all 1
ber_get_next
ber_get_next: tag 0x30 len 40 contents:
read1msg: ld 0x56538d980580 msgid 1 message type bind
ber_scanf fmt ({eAA) ber:
read1msg: ld 0x56538d980580 0 new referrals
read1msg:  mark request completed, ld 0x56538d980580 msgid 1
request done: ld 0x56538d980580 msgid 1
res_errno: 52, res_error: <Proxy operation retry failed>, res_matched: <>
ldap_free_request (origid 1, msgid 1)
ldap_parse_result
ber_scanf fmt ({iAA) ber:
ber_scanf fmt (}) ber:
ldap_msgfree
ldap_err2string
ldap_bind: Server is unavailable (52)
        additional info: Proxy operation retry failed
ldap_free_connection 1 1
ldap_send_unbind
ber_flush2: 7 bytes to sd 3
ldap_free_connection: actually freed

Mit diesem Kommande kann ich von der VM auf das AD zugreifen:
ldapsearch -H ldaps://hn-dc01.int.example.net -x -LLL \
    -D "cn=ldapsearch,cn=Users,dc=int,dc=example,dc=net" \  
    -b "cn=Users,dc=int,dc=example,dc=net" \  
    -W name
Also funktioniert wohl das CA-Zertifikat


Kann mir jemand sagen, was mein Denkfehler ist?
Komme da leider nicht drauf face-sad.

Vielen Dank euch.


Wenn ich die Frage nicht im richtigen Unterforum gepostet habe, bitte verschieben, oder mit das sagen.

Beste Grüße
jeschero

Content-Key: 516509

Url: https://administrator.de/contentid/516509

Ausgedruckt am: 19.03.2024 um 09:03 Uhr

Mitglied: Dani
Dani 18.11.2019 um 11:23:10 Uhr
Goto Top
Moin,
Kann mir jemand sagen, was mein Denkfehler ist?
direkt nicht - bin grad unterwegs. Aber hier zwei Referenz Konfigurationen:
https://gist.github.com/tuxfight3r/565dc060d2d5837f7349be9c0a1ea61b
https://linoxide.com/linux-how-to/configure-ad-authentication-ldap-proxy ...


Gruß,
Dani
Mitglied: jeschero
jeschero 18.11.2019 um 21:09:16 Uhr
Goto Top
Der Versuch mit diesem Link hat leider nicht geholfen:
https://linoxide.com/linux-how-to/configure-ad-authentication-ldap-proxy ...

/etc/ldap/slapd.conf
include /etc/ldap/schema/core.schema
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/inetorgperson.schema
include /etc/ldap/schema/nis.schema

## Module paths ##############################################################
modulepath      /usr/lib/ldap
moduleload      back_ldap
moduleload      rwm

database ldap
subordinate
rebind-as-user yes
uri             "ldaps://hn-dc01.example.net:636"  
suffix          "DC=int,DC=example,DC=net"  
chase-referrals yes
idassert-bind bindmethod=simple
binddn="CN=ldapsearch,CN=Users,DC=int,DC=example,DC=net"  
credentials="<passwd>"  
tls_cacert=/etc/ldap/certs/example-ADCA.crt

Fehlermeldung:
5dd2f5ef /etc/ldap/slapd.conf: line 12: subordinate configuration needs a suffix.
slaptest: bad configuration directory!

Aus dem Beitrag für subordinate werde ich leider nicht schlau:
https://linux.die.net/man/5/slapd.conf


Der anderen Link hat leider auch nicht geholfen:
https://gist.github.com/tuxfight3r/565dc060d2d5837f7349be9c0a1ea61b
Die Einstellungen bezüglich SSL für openldap habe ich ignoriert

/etc/ldap/slapd.conf
include /etc/ldap/schema/core.schema
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/inetorgperson.schema
include /etc/ldap/schema/nis.schema
include /etc/ldap/schema/misc.schema


#Global options
conn_max_pending 1000
sockbuf_max_incoming 4194303
loglevel 256
sizelimit unlimited
pidfile         /var/run/slapd/slapd.pid
argsfile        /var/run/slapd/slapd.args

#LDAP Proxy Options
modulepath /usr/lib/ldap
moduleload back_ldap
moduleload rwm
database ldap
suffix "dc=int,dc=example,dc=net"  
#subordinate
rebind-as-user yes
uri ldaps://hn-dc01.example.net
chase-referrals no
readonly yes
protocol-version 3
idassert-bind bindmethod=simple
    binddn="CN=ldapsearch,CN=Users,dc=int,dc=example,dc=net"  
    credentials="<passwd>"  
    tls_reqcert=never
    tls_cacert=/etc/ldap/certs/example-AdcA.pem

Command:
ldapsearch -H ldap://localhost -x -LLL     -D "cn=ldapsearch,cn=Users,dc=int,dc=example,dc=net"     -b "cn=Users,dc=int,dc=tecin,dc=net"     -W  name -d 5 

Result:
ldap_url_parse_ext(ldap://localhost)
ldap_create
ldap_url_parse_ext(ldap://localhost:389/??base)
ldap_sasl_bind
ldap_send_initial_request
ldap_new_connection 1 1 0
ldap_int_open_connection
ldap_connect_to_host: TCP localhost:389
ldap_new_socket: 3
ldap_prepare_socket: 3
ldap_connect_to_host: Trying ::1 389
ldap_pvt_connect: fd: 3 tm: -1 async: 0
attempting to connect:
connect success
ldap_open_defconn: successful
ldap_send_server_request
ber_scanf fmt ({it) ber:
ber_scanf fmt ({i) ber:
ber_flush2: 79 bytes to sd 3
ldap_result ld 0x55728b2db550 msgid 1
wait4msg ld 0x55728b2db550 msgid 1 (infinite timeout)
wait4msg continue ld 0x55728b2db550 msgid 1 all 1
** ld 0x55728b2db550 Connections:
* host: localhost  port: 389  (default)
  refcnt: 2  status: Connected
  last used: Mon Nov 18 21:07:00 2019


** ld 0x55728b2db550 Outstanding Requests:
 * msgid 1,  origid 1, status InProgress
   outstanding referrals 0, parent count 0
  ld 0x55728b2db550 request count 1 (abandoned 0)
** ld 0x55728b2db550 Response Queue:
   Empty
  ld 0x55728b2db550 response count 0
ldap_chkResponseList ld 0x55728b2db550 msgid 1 all 1
ldap_chkResponseList returns ld 0x55728b2db550 NULL
ldap_int_select
read1msg: ld 0x55728b2db550 msgid 1 all 1
ber_get_next
ber_get_next: tag 0x30 len 40 contents:
read1msg: ld 0x55728b2db550 msgid 1 message type bind
ber_scanf fmt ({eAA) ber:
read1msg: ld 0x55728b2db550 0 new referrals
read1msg:  mark request completed, ld 0x55728b2db550 msgid 1
request done: ld 0x55728b2db550 msgid 1
res_errno: 52, res_error: <Proxy operation retry failed>, res_matched: <>
ldap_free_request (origid 1, msgid 1)
ldap_parse_result
ber_scanf fmt ({iAA) ber:
ber_scanf fmt (}) ber:
ldap_msgfree
ldap_err2string
ldap_bind: Server is unavailable (52)
        additional info: Proxy operation retry failed
ldap_free_connection 1 1
ldap_send_unbind
ber_flush2: 7 bytes to sd 3
ldap_free_connection: actually freed
Mitglied: 132798
132798 19.11.2019 um 15:05:00 Uhr
Goto Top
Hallo jeschero,

vielleicht noch als alternativer Ansatz: UCS kommt mit OpenLDAP und neben vielem anderen mit einer optionalen, aber kostenfreien "AD-Connector"-Komponente, mit der man Benutzer und Gruppen aus einem Active Directory auslesen kann (per LDAPS). UCS selbst stellt das dann über OpenLDAP via LDAPS und LDAP bereit.
-> https://www.univention.de/produkte/univention-app-center/app-katalog/adc ...
Über UCS lassen sich dann auch weitere Apps wie z.B. ownCloud und Nextcloud mit fertiger LDAP-Anbindung installieren und einrichten.

Viele Grüße!