OpenLDAP (Ubuntu 14 04): Unterschied zwischen den Versionen
(→Links) |
(→Testen) |
||
Zeile 301: | Zeile 301: | ||
<pre> | <pre> | ||
ldapsearch -x -D cn=admin,dc=kirner,dc=or,dc=at -W -b dc=kirner,dc=or,dc=at | ldapsearch -x -D cn=admin,dc=kirner,dc=or,dc=at -W -b dc=kirner,dc=or,dc=at | ||
</pre> | |||
== Verwendung von SASL == | |||
<pre> | |||
sudo nano /etc/ldap/sasl-digestmd5.ldif | |||
</pre> | |||
<pre> | |||
########################################################### | |||
# DEFAULTS MODIFICATION for SASL DIGEST-MD5 | |||
########################################################### | |||
# Some of the defaults need to be modified in order to allow | |||
# SASL supported access to the LDAP config. | |||
# The LDAP administrator will need to tell the slapd server | |||
# how to map an authentication request DN to a user's | |||
# authentication DN. This is done by adding one or more | |||
# olcAuthzRegexp attributes to the cn=config backend. | |||
# This attribute takes two arguments: | |||
# | |||
# olcAuthzRegexp <search pattern> <replacement pattern> | |||
# | |||
# Please note, that more than one attribute can be specified. | |||
# The LDAP server will serve them sequentially. | |||
dn: cn=config | |||
changetype: modify | |||
add: olcAuthzRegexp | |||
olcAuthzRegexp: uid=root,cn=[^,]*,cn=auth cn=admin,dc=meinedomain,dc=local | |||
dn: cn=config | |||
changetype: modify | |||
add: olcAuthzRegexp | |||
olcAuthzRegexp: uid=([^,]*),cn=[^,]*,cn=auth uid=$1,ou=Users,dc=meinedomain,dc=local | |||
# set the correct authentication policy | |||
dn: cn=config | |||
changetype: modify | |||
add: olcAuthzPolicy | |||
olcAuthzPolicy: to | |||
# User passwords have to stored as cleartext within the | |||
# LDAP directory | |||
dn: olcDatabase={-1}frontend,cn=config | |||
changetype: modify | |||
add: olcPasswordHash | |||
olcPasswordHash: {CLEARTEXT} | |||
</pre> | </pre> | ||
Version vom 27. Juli 2016, 09:24 Uhr
Noch in Bearbeitung
Folgende Installationsanleitung erfordert in den meisten Fällen Rootrechte, daher wechseln wir fix zur root-Shell:
sudo -i
Installation
sudo apt-get install slapd ldap-utils
Folgendes Paket wird für das Samba-Schema benötigt:
sudo apt-get install samba-doc
Folgendes Paket wird für die Migration der Benutzerkonten benötigt:
sudo apt-get install smbldap-tools
sudo nano /etc/ldap/schema/schema_convert.conf
include /etc/ldap/schema/core.schema include /etc/ldap/schema/collective.schema include /etc/ldap/schema/corba.schema include /etc/ldap/schema/cosine.schema include /etc/ldap/schema/duaconf.schema include /etc/ldap/schema/dyngroup.schema include /etc/ldap/schema/inetorgperson.schema include /etc/ldap/schema/java.schema include /etc/ldap/schema/misc.schema include /etc/ldap/schema/nis.schema include /etc/ldap/schema/openldap.schema include /etc/ldap/schema/ppolicy.schema include /etc/ldap/schema/ldapns.schema include /etc/ldap/schema/pmi.schema include /etc/ldap/schema/samba.schema
Samba Schema kopieren
sudo cp /usr/share/doc/samba/examples/LDAP/samba.schema.gz /etc/ldap/schema sudo gzip -d /etc/ldap/schema/samba.schema.gz
Konvertieren ins LDIF-Format
sudo -i
Zuerst ein temporäres Verzeichnis erstellen:
mkdir /tmp/ldif_output
cd /etc/ldap/schema slapcat -f schema_convert.conf -F /tmp/ldif_output -n0 cd /tmp/ldif_output/cn\=config/cn\=schema/
sudo mv /etc/ldap/schema/*.ldif <backup dir> sudo cp <temp dir>/*.ldif /etc/ldap/schema/
Konfiguration
cd /etc/ldap/
slappasswd
/etc/ldap/db.ldif
nano /etc/ldap/db.ldif
Die Datei /etc/ldap/db.ldif mit folgenden Inhalt befüllen (2x Domänen und 2x Passwort ersetzen):
########################################################### # DEFAULT DATABASE MODIFICATION ########################################################### # Modify directory database dn: olcDatabase={1}hdb,cn=config changeType: modify delete: olcSuffix dn: olcDatabase={1}hdb,cn=config changeType: modify add: olcSuffix olcSuffix: dc=kirner,dc=or,dc=at dn: olcDatabase={1}hdb,cn=config changeType: modify delete: olcRootDN dn: olcDatabase={1}hdb,cn=config changeType: modify add: olcRootDN olcRootDN: cn=admin,dc=kirner,dc=or,dc=at dn: olcDatabase={1}hdb,cn=config changeType: modify delete: olcRootPW dn: olcDatabase={1}hdb,cn=config changeType: modify add: olcRootPW olcRootPW: {SSHA}<dx0sCgNBPlx98eRYnun1QBNfrWUR6qM1> dn: olcDatabase={1}hdb,cn=config changeType: modify delete: olcDbIndex dn: olcDatabase={1}hdb,cn=config changeType: modify add: olcDbIndex olcDbIndex: uid pres,eq dn: olcDatabase={1}hdb,cn=config changeType: modify add: olcDbIndex olcDbIndex: cn,sn,mail pres,eq,approx,sub dn: olcDatabase={1}hdb,cn=config changeType: modify add: olcDbIndex olcDbIndex: objectClass eq ########################################################### # REMOTE CONFIGURATION DEFAULTS ########################################################### # Some defaults need to be added in order to allow remote # access by DN cn=admin,cn=config to the LDAP config # database. Otherwise only local root will # administrative access. dn: olcDatabase={0}config,cn=config changetype: modify add: olcRootDN olcRootDN: cn=admin,cn=config dn: olcDatabase={0}config,cn=config changetype: modify add: olcRootPW olcRootPW: {SSHA}<dx0sCgNBPlx98eRYnun1QBNfrWUR6qM1>
ldapadd -Y EXTERNAL -H ldapi:/// -f db.ldif
/etc/ldap/base.ldif
nano /etc/ldap/base.ldif
Die Datei /etc/ldap/base.ldif mit folgenden Inhalt befüllen (auch hier wieder alle Domänen anpassen und das Passwort ersetzen):
# Tree root dn: dc=kirner,dc=or,dc=at objectClass: dcObject objectClass: organization o: kirner.or.at dc: kirner description: Tree root # LDAP admin dn: cn=admin,dc=kirner,dc=or,dc=at objectClass: simpleSecurityObject objectClass: organizationalRole cn: admin userPassword: {SSHA}<dx0sCgNBPlx98eRYnun1QBNfrWUR6qM1> description: LDAP administrator
ldapadd -x -D cn=admin,dc=kirner,dc=or,dc=at -W -f base.ldif
Benutzeraccounts nach LDAP migrieren
/etc/ldap/init.ldif
sudo nano /etc/ldap/init.ldif
dn: ou=Users,dc=kirner,dc=or,dc=at objectClass: organizationalUnit ou: Users dn: ou=Groups,dc=kirner,dc=or,dc=at objectClass: organizationalUnit ou: Groups dn: ou=Computers,dc=kirner,dc=or,dc=at objectClass: organizationalUnit ou: Computers dn: ou=Idmap,dc=kirner,dc=or,dc=at objectClass: organizationalUnit ou: Idmap
sudo ldapadd -x -h localhost -W -D cn=admin,dc=kirner,dc=or,dc=at -f init.ldif
cd /etc/smbldap-tools sudo zcat /usr/share/doc/smbldap-tools/examples/smbldap.conf.gz > smbldap.conf sudo cat /usr/share/doc/smbldap-tools/examples/smbldap_bind.conf > smbldap_bind.conf sudo chmod 0644 smbldap.conf sudo chmod 0600 smbldap_bind.conf
sudo nano /etc/smbldap-tools/smbldap.conf
/etc/smbldap-tools/smbldap_bind.conf
Wichtig ist Manager durch admin zu ersetzen.
sudo nano /etc/smbldap-tools/smbldap_bind.conf
############################ # Credential Configuration # ############################ # Notes: you can specify two differents configuration if you use a # master ldap for writing access and a slave ldap server for reading access # By default, we will use the same DN (so it will work for standard Samba # release) slaveDN="cn=admin,dc=kirner,dc=or,dc=at" slavePw="<password>" masterDN="cn=admin,dc=kirner,dc=or,dc=at" masterPw="<password>"
/etc/passwd
cd /root sudo zcat /usr/share/doc/smbldap-tools/examples/migration_scripts/smbldap-migrate-unix-accounts.gz > smbldap-migrate-unix-accounts sudo chmod u+x smbldap-migrate-unix-accounts sudo cp /etc/passwd passwd.users sudo nano passwd.users
Danach alle Benutzer entfernen, die nicht übertragen werden sollen (z.B. root).
./smbldap-migrate-unix-accounts -P passwd.users -S /etc/shadow -v
/etc/group
sudo zcat /usr/share/doc/smbldap-tools/examples/migration_scripts/smbldap-migrate-unix-groups.gz > smbldap-migrate-unix-groups sudo chmod u+x smbldap-migrate-unix-groups sudo cp /etc/group group.import sudo nano group.import
Danach alle Gruppen entfernen, die nicht übertragen werden sollen (z.B. root).
./smbldap-migrate-unix-groups -G group.import -v
Migration testen
ldapsearch -x -D cn=admin,dc=kirner,dc=or,dc=at -W -b dc=kirner,dc=or,dc=at
Verwendung von SASL
sudo nano /etc/ldap/sasl-digestmd5.ldif
########################################################### # DEFAULTS MODIFICATION for SASL DIGEST-MD5 ########################################################### # Some of the defaults need to be modified in order to allow # SASL supported access to the LDAP config. # The LDAP administrator will need to tell the slapd server # how to map an authentication request DN to a user's # authentication DN. This is done by adding one or more # olcAuthzRegexp attributes to the cn=config backend. # This attribute takes two arguments: # # olcAuthzRegexp <search pattern> <replacement pattern> # # Please note, that more than one attribute can be specified. # The LDAP server will serve them sequentially. dn: cn=config changetype: modify add: olcAuthzRegexp olcAuthzRegexp: uid=root,cn=[^,]*,cn=auth cn=admin,dc=meinedomain,dc=local dn: cn=config changetype: modify add: olcAuthzRegexp olcAuthzRegexp: uid=([^,]*),cn=[^,]*,cn=auth uid=$1,ou=Users,dc=meinedomain,dc=local # set the correct authentication policy dn: cn=config changetype: modify add: olcAuthzPolicy olcAuthzPolicy: to # User passwords have to stored as cleartext within the # LDAP directory dn: olcDatabase={-1}frontend,cn=config changetype: modify add: olcPasswordHash olcPasswordHash: {CLEARTEXT}
Testen
Datenbanken liegen auf /var/lib/ldap
Datenbanktyp eventuell von hdb auf mdb ändern
ldapsearch -xLLL -b cn=config -D cn=admin,cn=config -W olcDatabase={1}hdb ldapsearch -xLLL -b cn=config -D cn=admin,cn=config -W
ldapsearch -xLLL -b dc=kirner,dc=or,dc=at
Sichern
sudo cp -rp /var/lib/ldap/ /var/lib/ldap.bak sudo cp -rp /etc/ldap/slapd.d /etc/ldap/slapd.d.bak
Probleme
root@VBox-16-4-Server:/etc/ldap# ldapadd -Y EXTERNAL -H ldapi:/// -f db.ldif SASL/EXTERNAL authentication started SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth SASL SSF: 0 modifying entry "olcDatabase={1}hdb,cn=config" ldap_modify: No such object (32) matched DN: cn=config root@VBox-16-4-Server:/etc/ldap# ldapsearch -H ldapi:// -Y EXTERNAL -b "cn=config" -LLL -Q "olcDatabase=*" dn dn: olcDatabase={-1}frontend,cn=config dn: olcDatabase={0}config,cn=config dn: olcDatabase={1}mdb,cn=config
Links
https://wiki.ubuntuusers.de/OpenLDAP_ab_Precise/
https://help.ubuntu.com/lts/serverguide/openldap-server.html
http://linx-qh.de/openldap-server-auf-ubuntu-server-14-04-installieren-und-einrichten/
https://wiki.ubuntuusers.de/Archiv/OpenLDAP/#migration
Zurück zu Ubuntu