OpenLDAP: Unterschied zwischen den Versionen

Aus Hostsharing Wiki
Zur Navigation springen Zur Suche springen
Zeile 345: Zeile 345:
   changetype: modify
   changetype: modify
   replace: mail
   replace: mail
   mail: mmustermann@example.org
   mail: mmustermann2@example.org


Dann ausführen:
Dann ausführen:
  ldapmodify -H ldap://127.0.0.1:$PORT -D "cn=admin,$BASE_DN" -W -f modify_email.ldif  
  ldapmodify -H ldap://127.0.0.1:$PORT -D "cn=admin,$BASE_DN" -W -f modify_email.ldif


=== Benutzer löschen ===
=== Benutzer löschen ===

Version vom 5. Mai 2023, 09:26 Uhr


Diese Seite muss überarbeitet werden

Diese Seite wurde als Baustelle gekennzeichnet, weil sie überarbeitet werden muss. Eine Begründung dafür findest du auf der Diskussionsseite. Bitte hilf mit, diese Seite zu verbessern!

OpenLDAP installieren

Voraussetzung: Das Debian-Paket "slapd" ist auf dem Managed Server vorinstalliert.

#!/bin/sh

BASE_DIR="${HOME}/slapd2"
BASE_DN="dc=example,dc=com"

INITIAL_PASSWORD="myInitialPassword"

BIND_IP_ADDR="127.0.0.1"
BIND_IP_PORT="12345"


############################################################################


# Fail, if base directory already exists

if test -e ${BASE_DIR}; then
    echo "Initialization failed." >&2
    echo "Base directory already exists." >&2
    exit 1
fi


# Create directory

mkdir -p -m 700 ${BASE_DIR}
cd ${BASE_DIR}


# Unpack initital configuration

cat <<EOF |base64 -d |tar -xz
H4sIALShi2IAA+w9a3PjNpLzGb8Cm0yVPXexI74ky1v5oNhOynse22vZqWS/XFEkZHOHIhWKmrE3
Nf/9GgDx4AMQZWtcud1R1ZQloUV0o5/obmBIGX3/5gu/BvAaDQZvBp47CgKXfXZ8n/2tXm8c3/Xd
kTvwAvjeGQSe+wYHXxox+lqvyrDAGP6Swg5HitVrIPS6LwL8j7IfojybJ/dfSBIY/4OgB/+d0Wg0
BP67vh985f9rvOr8h3eLPF6n5I/B58M0TuY7mYMyeEj5beD/aDAU/HdhBPgfDD3vDR7sZPYNr/9w
/n+LJ3e3V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kgOcaIUumo0LHHRRZ76RI2dzkuUtjz81f+4yz+L3Qj2nlg2HmW3TS/EUNAVZoR
KDBPDSPZhwsj9U3b+HMmBCr4vw+wryg78B+GRY7/0DAOHDfhws7/c5DySvyfz10vKPg/amz+T6t0
7q9ovp9k36+XG0wbloB8/ZCcblZ+Fp74cJJiYrqk5NNnCMIUgqdxWHtXFlMgvU3T1e0dwiq83mwA
Gy5XyTy33EXJPPff3jy3vUHLOPV+cQUb700H2F94/Lfe/yvHf2ks0DANZ2B18d9DFLCd/s/636b9
b/e7/u9KV7rSla50pStd6UpXutKVrnSlK13pSle60pWudKUrXXlJ+R8PJCZ+APAAAA==
EOF


# Patch configuration files

sed -e"s%BASE_DIR%${BASE_DIR}%" -i $(find -name \*.ldif)
sed -e"s%BASE_DN%${BASE_DN}%" -i $(find -name \*.ldif)
sed -e"s%INITIAL_PASSWORD%${INITIAL_PASSWORD}%" -i $(find -name \*.ldif)


# Fix CRC32 checksums on configuration files

for FILE in $(find -name \*.ldif); do
    CRC32=$(tail -n +3 ${FILE} |crc32 /dev/stdin)
    sed -e"s/^# CRC32 [0-9a-f]*$/# CRC32 ${CRC32}/" -i ${FILE}
done


# Add Root DSE

DC=$(echo ${BASE_DN} |cut -d "," -f1 |cut -d "=" -f2)

cat <<EOF |/usr/sbin/slapadd -F "${BASE_DIR}/etc" -b ${BASE_DN}
dn: ${BASE_DN}
dc: ${DC}
objectClass: domain
objectClass: top
structuralObjectClass: domain
EOF


# Print instructions

cat <<EOF

Instructions
============

Launch slapd (debug level 0 - foreground mode)
$ /usr/sbin/slapd -h "ldap://${BIND_IP_ADDR}:${BIND_IP_PORT}/" -F "${BASE_DIR}/etc" -d 0

LDAPvi on cn=config
$ ldapvi -h "ldap://${BIND_IP_ADDR}:${BIND_IP_PORT}/" -D "cn=admin,cn=config" -b "cn=config"

LDAPvi on dc=hostsharing,dc=net
$ ldapvi -h "ldap://${BIND_IP_ADDR}:${BIND_IP_PORT}/" -D "cn=admin,${BASE_DN}" -b "${BASE_DN}"

Do not forget to update the intitial passwords for both identities:

    cn=admin,cn=config
    cn=admin,${BASE_DN}

EOF

Basis-Struktur ergänzen

Für viele Anwendungsfälle – wie eine Synchronisation mit Keycloak – wird empfohlen noch zwei Organizational Units zu ergänzen:

Editor starten mit:

ldapvi -h "ldap://127.0.0.1:12345/" -D "cn=admin,dc=example,dc=com" -b "dc=example,dc=com" 

Oben die folgenden Zeilen ergänzen:

add ou=users,dc=example,dc=com
objectClass: organizationalUnit
objectClass: top
ou: users
add ou=groups,dc=example,dc=com
objectClass: organizationalUnit
objectClass: top
ou: groups

Nun den Editor schließen und noch mit y bestätigen.

Autostart

Um den neuen LDAP-Dienst dauerhaft laufen zu lassen, können beispielsweise Monit oder Systemd genutzt werden. Hier ein Beispiel für Letzteres:

mkdir -p .config/systemd/user

In das Verzeichnis die Datei slapd.service legen und mit beispielsweise den folgenden Inhalten befüllen:

Description=Slapd2 Server

[Service]
Type=simple
Restart=on-abort
WorkingDirectory=/home/pacs/xyz00/users/ldap/

# eg -d 255 for higher loglevel
ExecStart=/usr/sbin/slapd -h ldap://127.0.0.1:12345/ -F /home/pacs/xyz00/users/ldap/slapd2/etc -d 0
PIDFile=/home/pacs/xyz00/users/ldap/slapd2/run/slapd.pid

[Install]
WantedBy=default.target

Im Anschluss:

systemctl enable --user slapd
systemctl start --user slapd

Hinweis: unter Umständen muss ein Administator diese Funktionalität erst für Sie freischalten. Ihr User benötigt womöglich außerdem die folgende Umgebungsvariable um die Befehle ausführen zu können:

export XDG_RUNTIME_DIR=/run/user/$UID

Pflege der LDAP Daten über die Kommandozeile

Benutzer anlegen

Datei adduser.ldif (entsprechende Werte ersetzen):

dn: uid=mmustermann,ou=users,dc=example,dc=org
objectClass: inetOrgPerson
cn: Max
sn: Mustermann
uid: mmustermann
userPassword: TopSecret1234
mail: mmustermann@example.org

Dann ausführen:

ldapadd -H ldap://127.0.0.1:$PORT -D "cn=admin,$BASE_DN" -W  -f adduser.ldif

Passwort von Benutzer ändern

export PORT=30389
export BASE_DN="dc=example,dc=org"
ldappasswd -H ldap://127.0.0.1:$PORT -x -D "cn=admin,$BASE_DN" -W -S "uid=mmustermann,ou=users,$BASE_DN"

Nach Benutzern suchen

export PORT=30389
export BASE_DN="dc=example,dc=org"
ldapsearch -x -b "$BASE_DN" -H ldap://127.0.0.1:$PORT # geht sogar ohne Benutzer
ldapsearch -x -b "$BASE_DN" -H ldap://127.0.0.1:$PORT -D "cn=admin,$BASE_DN" -W
ldapsearch -x -b "$BASE_DN" -H ldap://127.0.0.1:$PORT -D "cn=admin,cn=config" -W

Was kann der normale Benutzer sehen:

ldapsearch -x -b "$BASE_DN" -H ldap://127.0.0.1:$PORT -D "uid=mmustermann,ou=users,$BASE_DN" -W

nach Personen mit bestimmter Klasse suchen:

ldapsearch -x -b "$BASE_DN" -H ldap://127.0.0.1:$PORT -D "cn=admin,$BASE_DN" -W "objectClass=inetOrgPerson"

Eigenschaften aktualisieren

Datei modify_email.ldif:

 dn: uid=mmustermann,ou=users,dc=example,dc=org
 changetype: modify
 replace: mail
 mail: mmustermann2@example.org

Dann ausführen:

ldapmodify -H ldap://127.0.0.1:$PORT -D "cn=admin,$BASE_DN" -W -f modify_email.ldif

Benutzer löschen

ldapdelete -H ldap://127.0.0.1:$PORT -D "cn=admin,$BASE_DN" -W "uid=mmustermann,ou=users,$BASE_DN"

Gruppe löschen

Datei delete_group.ldif:

 dn: cn=Test,ou=groups,dc=example,dc=org
 changetype: delete

Dann ausführen:

ldapmodify -H ldap://127.0.0.1:$PORT -D "cn=admin,$BASE_DN" -W -f delete_group.ldif

Links