Public Domain Contoller HowTo

Vorwort

Oft wurde das Thema behandelt und selten finde ich mich zurecht, wenn ich andere Howtos lese. Hier ist nun meine Version.

Das hier eingerichtet System hat folgende Komponenten:

  1. Samba (als Dateiserver)
  2. ldap (als Authentifizierungs-Dienst)
  3. LAM (LDAP Account Manager zum Administrieren)

Der Samba und LDAP Server werden nicht auf einer Maschine laufen. Aus diesem Grund wird jedes Mal daraufhingewiesen, auf welchem Rechner Installiert bzw. Konfiguriert wird.

  • :!: SAMBA (bedeutet, daß wir uns gerade auf dem Samba Server befinden)
  • :!: LDAP (bedeutet, daß wir uns gerade auf dem LDAP Server befinden)

Installation

LDAP

:!: LDAP

apt-get install slapd ldap-utils

Konsole

Fragen zu slapd

  1. Omit OpenLDAP server configuration? : no
  2. DNS domain name : buerovs.intern
  3. Name of your organization: example_organization
  4. Admin password: <administrative LDAP password>
  5. Database backend to use: BDB
  6. Do you want your database to be removed when slapd is purged? no
  7. Allow LDAPv2 protocol? no

Samba

:!: SAMBA

apt-get install samba samba-doc

Konsole

Alle Fragen können irgendwie beantwortet werden, denn die Konfigurationsdatei wird komplett umgeschrieben werden!

Nun wird die Schemadatei von Samba für LDAP kopiert:

cp /usr/share/doc/samba-doc/examples/LDAP/samba.schema.gz /etc/ldap/schema/
cd /etc/ldap/schema/
gunzip samba.schema.gz

Konsole

nss-ldap

:!: SAMBA

Das Programm passwd nutzt die Konfigurationsdatei /etc/nsswitch.conf um herauszufinden, welche Passwörter zu ändern sind. Damit es LDAP „versteht“, muß die entsprechende Bibliothek installiert werden.

apt-get install libnss-ldap

Konsole

Fragen zu libnss-ldap

  1. LDAP-Server: ldap://192.168.0.194/
  2. DN (distinguished name) der Suchbasis: dc=buerovs,dc=intern
  3. LDAP-Version: 3
  4. Datenbank benötigt Login: nein
  5. special Privlileges for root: ja
  6. Nur für Eigentümer les-/schreibbar: nein
  7. LDAP account for root: cn=admin,dc=buerovs,dc=intern
  8. LDAP root account password: <secret>

smbldap-tools

:!: SAMBA

Damit Samba auch mit LDAP zusammenarbeiten kann, benötigt man weitere Pakete:

apt-get install smbldap-tools

Konsole

Die Konfiguration wird später vorgenommen.

Konfiguration

Die Konfiguration beginnt mit dem Samba Server, obwohl noch keine Anbindung an LDAP besteht. Dieses ist sinnvoll, da so alle weiteren Änderungen sich direkt auf Samba auswirken.

Samba

:!: SAMBA

Die für Samba wichtige Konfigurationsdatei ist etc/samba/smb.conf. Sollte bereit eine vorhanden sein, kann man sie sichern und eine leere neue Datei anlegen:

cd /etc/samba
mv smb.conf smb.conf.orig
touch smb.conf

Konsole

Im Folgenden werden nicht alle Optionen genau beschrieben. Diese können aber in der Manual-Page (man smb.conf) nachgelesen werden.

Nun werden zunächst die allgemeinen Einstellungen getätigt.

[global]
## Browsing/Identification ###
 
   netbios name = lserver
   netbios aliases = bueroserver buerovslserver
   workgroup = buerovs
   server string = PDC %h (Samba %v)
 
   wins support = yes
   name resolve order = lmhosts host wins bcast

/etc/samba/smb.conf --- [global] -- Teil 1

#### Networking ####
 
;   interfaces = 127.0.0.0/8 eth0
;   bind interfaces only = true
;   hosts allow = 10.0.0.0/24 10.1.0.0/24 10.2.0.0/24

/etc/samba/smb.conf --- [global] -- Teil 2

#### Debugging/Accounting ####
 
# This tells Samba to use a separate log file for each machine
# that connects
;   log file = /var/log/samba/log.%m
 
   max log size = 1000
   log level = 0
   syslog only = no
   syslog = 0
 
# Do something sensible when Samba crashes: mail the admin a backtrace
   panic action = /usr/share/samba/panic-action %d

/etc/samba/smb.conf --- [global] -- Teil 3

####### Authentication #######
 
# "security = user" is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba-HOWTO-Collection/ServerType.html
# in the samba-doc package for details.
   security = user
 
   encrypt passwords = true
   null passwords = no
# Never use this option: you will not add windows hosts to domain!
;   invalid users = root
 
   passwd chat = *new*password* %n\n *new*password* %n\n *changed*
;   passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n *password\supdated\ssuccessfully* .
   passdb backend = ldapsam:ldap://<IP-to-LDAP-Server/
 
   ldap passwd sync = yes
   ldap delete dn = Yes
 
   ldap admin dn = cn=admin,dc=buerovs,dc=intern
;   ldap admin dn = cn=samba,ou=DSA,dc=buerovs,dc=intern
   ldap suffix = dc=buerovs
   ldap group suffix = ou=Groups
   ldap user suffix = ou=Users
   ldap machine suffix = ou=Computers
   ldap idmap suffix = ou=Users
 
   add machine script = /usr/sbin/smbldap-useradd -w "%u"
   add user script = /usr/sbin/smbldap-useradd -m "%u"
   add group script = /usr/sbin/smbldap-groupadd -p "%g"
   add user to group script = /usr/sbin/smbldap-groupmod -m "%u" "%g"
   delete user from group script = /usr/sbin/smbldap-groupmod -x "%u" "%g"
   set primary group script = /usr/sbin/smbldap-usermod -g "%g" "%u"
 
;   guest account = nobody

/etc/samba/smb.conf --- [global] -- Teil 4

########## Domains ###########
 
   local master = yes
   os level = 65
   preferred master = yes
   domain master = yes
 
   domain logons = yes
 
# The following required a [profiles] share
   logon path = \\%L\profiles\%U
 
# It specifies the location of a user's home directory (from the client
# point of view)
   logon drive = Z:
   logon home = \\%L\%U
 
# It specifies the script to run during logon. The script must be stored
# in the [netlogon] share
# NOTE: Must be store in 'DOS' file format convention
   logon script = logon.cmd
 
   hide unreadable = yes
   hide dot files = yes

/etc/samba/smb.conf --- [global] -- Teil 5

############ Misc ############
 
   dos charset = 850
   unix charset = UTF-8
 
# Using the following line enables you to customise your configuration
# on a per machine basis. The %m gets replaced with the netbios name
# of the machine that is connecting
;   include = /home/samba/etc/smb.conf.%m
 
# Most people will find that this option gives better performance.
# See smb.conf(5) and /usr/share/doc/samba-doc/htmldocs/speed.html
# for details
# You may want to add the following on a Linux system:
#         SO_RCVBUF=8192 SO_SNDBUF=8192
   socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

/etc/samba/smb.conf --- [global] -- Teil 6

Die weiteren Abschnitte sind für die Anmeldung an der Domäne:

[netlogon]
   comment = Network Logon Service
   path = /home/samba/netlogon
   public = no
   writable = no
   browsable = no
;   guest ok = yes
   share modes = no

/etc/samba/smb.conf --- [netlogon]

# The path below should be writable by all users so that their
# profile directory may be created the first time they log on
[profiles]
   comment = Users profiles
   path = /home/samba/profiles
   guest ok = no
   browseable = no
   writable = yes
;   write list =
   create mask = 0600
   directory mask = 0700
   default case = lower
   preserve case = no
   case sensitive = no

/etc/samba/smb.conf --- [profiles]

[homes]
   comment = Home Directories
   path = /home/%U/.windows_home
   create mask = 0700
   directory mask = 0700
   browseable = no
   writable = yes
   valid users = %S
   public = no
   guest ok = no
   inherit permissions = yes

/etc/samba/smb.conf --- [homes]

Damit für einen neuen Benutzer das Windows Home-Verzeichnis auch vorhanden ist, muß dieses in /etc/skel/ angelegt werden:

mkdir /etc/skel/.windows_home

Konsole

Der Samba Dienst muß nach der Konfiguration erfolgreich neu gestartet werden.

Man kann die Konfiguration mit dem Programm testparam prüfen. Das ist aber keine 100%ige Garantie!

LDAP Server

:!: LDAP

Für die Konfiguration des LDAP Server muß als erstes die Datei /etc/ldap/slapd.conf editiert werden:

#######################################################################
# Global Directives:

# Features to permit
#allow bind_v2

# Schema and objectClass definitions
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/samba.schema

schemacheck     on

# Where the pid file is put. The init.d script
# will not stop the server if you change this.
pidfile         /var/run/slapd/slapd.pid

# List of arguments that were passed to the server
argsfile        /var/run/slapd/slapd.args

loglevel        1480
#loglevel        0

# Where the dynamically loaded modules are stored
modulepath      /usr/lib/ldap
moduleload      back_bdb

# The maximum number of entries that is returned for a search operation
#sizelimit unlimited
sizelimit 500  # default

# The tool-threads parameter sets the actual amount of cpu's that is used
# for indexing.
tool-threads 1

/etc/ldap/slapd.conf --- Teil 1

#######################################################################
# Specific Backend Directives for bdb:
# Backend specific directives apply to this backend until another
# 'backend' directive occurs
backend         bdb
checkpoint 512 30

# Specific Directives for database #1, of type bdb:
# Database specific directives apply to this databasse until another
# 'database' directive occurs
database        bdb

# The base of your directory in database #1
suffix          "dc=buerovs,dc=intern"

# rootdn directive for specifying a superuser on the database. This is needed
# for syncrepl.
rootdn          "cn=admin,dc=buerovs,dc=intern

# Where the database file are physically stored for database #1
directory       "/var/lib/ldap"

# For the Debian package we use 2MB as default but be sure to update this
# value if you have plenty of RAM
dbconfig set_cachesize 0 2097152 0

# Sven Hartge reported that he had to set this value incredibly high
# to get slapd running at all. See http://bugs.debian.org/303057
# for more information.

# Number of objects that can be locked at the same time.
dbconfig set_lk_max_objects 1500
# Number of locks (both requested and granted)
dbconfig set_lk_max_locks 1500
# Number of lockers
dbconfig set_lk_max_lockers 1500

# Indexing options for database #1
index        objectClass,uidNumber,gidNumber               eq
index        cn,sn,uid,displayName                         pres,sub,eq
index        memberUid,mail,givenname                      eq,subinitial
index        sambaSID,sambaPrimaryGroupSID,sambaDomainName eq

# Save the time that the entry gets modified
lastmod         on

# Where to store the replica logs
# replogfile    /var/lib/ldap/replog

# Use MD5-Hashes of Unix passwords
password-hash  {crypt}
password-crypt-salt-format   "$1$%.8s"

# ACLs...

access to dn.base="" by * read

# The admin dn has full write access, everyone else
# can read everything.
access to *
        by dn="cn=admin,dc=buerovs,dc=intern" write
        by self read
        by * read

/etc/ldap/slapd.conf --- Teil 2

Nun muß das Passwort des LDAP Administrators verschlüsselt in die Datei eingetragen werden:

echo "rootpw " $(slappasswd -h {SSHA} -s meinpasswort) >> /etc/ldap/slapd.conf

Konsole

Der LDAP Dienst muß nach der Konfiguration erfolgreich neu gestartet werden.

Zugriff von Samba auf LDAP

:!: SAMBA

Als nächstes sorgen wir dafür, daß Samba den Zugriff auf LDAP erhält:

smbpasswd -w meinpasswort
 
Output...
Setting stored password for "cn=admin,dc=buerovs" in secrets.tdb

Konsole

Der SAMBA Dienst muß nun erfolgreich neu gestartet werden.

LDAP Client

FIXME Nich klar wo es notwendig ist.

Da auch andere Dienste auf LDAP zugreifen, muß man eine LDAP Client Konfiguration erstellen:

HOST 127.0.0.1
BASE dc=buerovs,dc=intern

/etc/ldap/ldap.conf

nss-ldap

:!: SAMBA

Nun wird dem System die Nutzen- und Gruppenkonten, die im LDAP gespeichert werden, bekannt gemacht. Dieses ist notwendig, damit die UIDs und GIDs zugeordnet werden können. Hier ist nur der wichtige Ausschnitt der Datei, die gesamte Datei kann man hier herunterladen.

# This is the configuration file for the LDAP nameservice
# switch library and the LDAP PAM module.
#

# The distinguished name of the search base.
base dc=buerovs,dc=intern

# Another way to specify your LDAP server is to provide an
uri ldap://192.168.0.194/

# The LDAP version to use (defaults to 3
# if supported by client library)
ldap_version 3

# The distinguished name to bind to the server with.  Optional: default is to
# bind anonymously.  Please do not put double quotes around it as they would be
# included literally.
binddn cn=admin,dc=buerovs,dc=intern
bindpw meinpasswort

# The distinguished name to bind to the server with if the effective user ID is
# root. Password is stored in /etc/libnss-ldap.secret (mode 600)
# Use 'echo -n "mypassword" > /etc/libnss-ldap.secret' instead of an editor to
# create the file.
rootbinddn cn=admin,dc=buerovs,dc=intern

pam_password md5

# RFC2307bis naming contexts
# Syntax:
# nss_base_XXX          base?scope?filter
# where scope is {base,one,sub}
# and filter is a filter to be &'d with the default filter.
# You can omit the suffix eg:
# nss_base_passwd       ou=People,
# to append the default base DN but this may incur a small performance impact.
nss_base_passwd         ou=Users,dc=buerovs,dc=intern?one
nss_base_passwd         ou=Computers,dc=buerovs,dc=intern?one
nss_base_shadow         ou=Users,dc=buerovs,dc=intern?one
nss_base_group          ou=Groups,dc=buerovs,dc=intern?one

/etc/libnss-ldap.conf

Der Zusatz ?one bewirkt, daß maximal eine Antwort vom LDAP-Server zurückgeliefert wird.

Damit das System nach den angeforderten Einträgen sucht, muß die Datei /etc/nsswitch.conf angepaßt werden:

passwd:         compat ldap
group:          compat ldap
shadow:         compat ldap

/etc/nsswitch.conf -- Änderungen

Die Erweiterung bewirkt, daß die Suche nach Einträgen auf dem LDAP-Server fortgesetzt wird, wenn keine in den Dateien gefunden wurden.

smbldap-tools

:!: SAMBA

Diese Tools verknüpfen Samba und den LDAP Server. Dazu müssen die Passwörter angegeben werden.

<file|/etc/smbldap-tools/smbldap_bind.conf> slaveDN=„cn=admin,dc=buerovs,dc=intern“ slavePw=„meinpasswort“ masterDN=„cn=admin,dc=buerovs,dc=intern“ masterPw=„meinpasswort“ </file>

Diese Datei muß noch vor dem Zugriff anderer geschützt werden.

chmod 0400 /etc/smbldap-tools/smbldap_bind.conf

Konsole

Es muß noch die /etc/smbldap-tools/smbldap.conf editiert werden. Sollte keine vorhanden sein, so kann man sie aus dem doc-Vereichnis kopieren. Hier kann man die gesamte Datei herunterladen.

Um die SID in dieser Datei auf den korrekten Wert zu setzten, muß man den Wert erst auslesen:

net getlocalsid

Konsole

# smbldap-tools.conf : Q & D configuration file for smbldap-tools

##############################################################################
#
# General Configuration
#
##############################################################################

# Put your own SID. To obtain this number do: "net getlocalsid".
# If not defined, parameter is taking from "net getlocalsid" return
SID="S-1-5-21-938990727-2293754504-940761264"

sambaDomain="BUEROVS"

##############################################################################
#
# LDAP Configuration
#
##############################################################################

# Slave LDAP server
slaveLDAP="192.168.0.194"
slavePort="389"

# Master LDAP server: needed for write operations
masterLDAP="192.168.0.194"
masterPort="389"

# Use TLS for LDAP
ldapTLS="0"
verify="require"

# CA certificate
cafile="/etc/opt/IDEALX/smbldap-tools/ca.pem"
clientcert="/etc/opt/IDEALX/smbldap-tools/smbldap-tools.pem"
clientkey="/etc/opt/IDEALX/smbldap-tools/smbldap-tools.key"

# LDAP Suffix
suffix="dc=buerovs,dc=intern"

# Where are stored Users
usersdn="ou=Users,${suffix}"

# Where are stored Computers
computersdn="ou=Computers,${suffix}"

# Where are stored Groups
groupsdn="ou=Groups,${suffix}"

# Where are stored Idmap entries (used if samba is a domain member server)
idmapdn="ou=Idmap,${suffix}"

# Where to store next uidNumber and gidNumber available for new users and groups
sambaUnixIdPooldn="sambaDomainName=BUEROVS,${suffix}"

# Default scope Used
scope="sub"

# Unix password encryption (CRYPT, MD5, SMD5, SSHA, SHA, CLEARTEXT)
hash_encrypt="CRYPT"

# if hash_encrypt is set to CRYPT, you may set a salt format.
crypt_salt_format="$1$%.8s"

/etc/smbldap-tools/smbldap.conf -- Teil 1

##############################################################################
#
# Unix Accounts Configuration
#
##############################################################################

# Default Login Shell
userLoginShell="/bin/bash"

# Home directory
userHome="/home/%U"

# Default mode used for user homeDirectory
userHomeDirectoryMode="700"

# Gecos
userGecos="System User"

# Default User (POSIX and Samba) GID
defaultUserGid="513"

# Default Computer (Samba) GID
defaultComputerGid="515"

# Skel dir
skeletonDir="/etc/skel"

# Default password validation time (time in days)
defaultMaxPasswordAge="365"

##############################################################################
#
# SAMBA Configuration
#
##############################################################################

## leere Strings bedeutet, daß der Wert aus der smb.conf gelesen wird!
# The UNC path to home drives location ('logon home')
userSmbHome=""

# The UNC path to profiles locations ('logon path')
userProfile=""

# The default Home Drive Letter mapping
userHomeDrive="Z:"

# The default user netlogon script name (%U username substitution)
# make sure script file is edited under dos
userScript="logon.cmd"

# Domain appended to the users "mail"-attribute when smbldap-useradd -M
mailDomain="buerovs.intern"

##############################################################################
#
# SMBLDAP-TOOLS Configuration (default are ok for a RedHat)
#
##############################################################################

with_smbpasswd="0"
smbpasswd="/usr/bin/smbpasswd"

with_slappasswd="0"
slappasswd="/usr/sbin/slappasswd"

# no_banner="1"

/etc/smbldap-tools/smbldap.conf -- Teil 2

Initialisieren des LDAP Verzeichnisses

Nachdem alles eingestellt ist, muß die Struktur für den Samba PCD in LDAP angelegt werden.

smbldap-populate

Nun sollte der Samba Service neu gestartet werden.

Sicherheit

Bisher ist alles so konfiguriert, daß die verschiedenen Dienste oder Programme immer das admin-Passwort des LDAP-Nutzers kennen muß. Da dieses zu Sicherheitsproblemen führen kann, wird im folgenden beschreiben, wie man verschiedene „Systemnutzer“ und Passwörter nutzern und erstellen kann.

Zugriffskontrolle

Jeder Dienst, der die LDAP-Daten nutzen möchte, erhält ein eigenes Zugriffskonto. Dieses betrifft

  1. den Samba-Server.
  2. das PAM LDAP Modul (libpam-ldap).
  3. die Samba LDAP Tools.

Erstellen der neuen Systemnutzer

:!: LDAP

Dazu muß eine .ldif Datei mit den benötigten Informationen erstellt werden:

dn: ou=DSA,dc=buerovs,dc=intern
objectClass: top
objectClass: organizationalUnit
ou: DSA
description: security accounts for LDAP clients

dn: cn=samba,ou=DSA,dc=buerovs,dc=intern
objectclass: organizationalRole
objectClass: top
objectClass: simpleSecurityObject
userPassword: sambasecretpwd
cn: samba

dn: cn=nssldap,ou=DSA,dc=buerovs,dc=intern
objectclass: organizationalRole
objectClass: top
objectClass: simpleSecurityObject
userPassword: nssldapsecretpwd
cn: nssldap

dn: cn=smbldap-tools,ou=DSA,dc=buerovs,dc=intern
objectclass: organizationalRole
objectClass: top
objectClass: simpleSecurityObject
userPassword: smbldapsecretpwd
cn: smbldap-tools

ldap-security.ldif

Diese Datei muß in LDAP importiert werden:

ldapadd -x -h localhost -D "cn=admin,dc=buerovs,dc=intern" -f ldap-security.ldif -W

Konsole

Jetzt sind die Datein eingetragen. Die Passwörter sind allerdings im Klartext eingetragen. Aus Sicherheitsgründen ändert man dieses mit Hilfe der folgenden Befehle:

ldappasswd -x -h localhost -D "cn=admin,dc=buerovs,dc=intern" -s sambasecretpwd -W cn=samba,ou=DSA,dc=buerovs,dc=intern
ldappasswd -x -h localhost -D "cn=admin,dc=buerovs,dc=intern" -s nssldapsecretpwd -W cn=nssldap,ou=DSA,dc=buerovs,dc=intern
ldappasswd -x -h localhost -D "cn=admin,dc=buerovs,dc=intern" -s smbldapsecretpwd -W cn=smbldap-tools,ou=DSA,dc=buerovs,dc=intern

Konsole

Konfiguration anpassen

smbldap_bind.conf

:!: SAMBA

Als erstes muß die Samba LDAP Werkzeuge angepaßt werden. Dazu müssen folgende Werte angepaßt werden:

slaveDN="cn=smbldap-tools,ou=DSA,dc=buerovs,dc=intern"
slavePw="smbldapsecretpwd"
masterDN="cn=smbldap-tools,ou=DSA,dc=buerovs,dc=intern"
masterPw="smbldapsecretpwd"

/etc/smbldap-tools/smbldap_bind.conf

smb.conf

:!: SAMBA

Anschließend muß die Samba Konfigurationsdatei abgeändert werden:

ldap admin dn = cn=samba,ou=DSA,dc=buerovs,dc=intern

/etc/samba/smb.conf -- Zeile 77

Jetzt müssen die Änderungen dem Samba Server bekannt gegeben werden:

smbpasswd -w sambasecretpwd

Konsole

Ein Neustart des Samba-Dienstes kann nicht schaden.

slapd.conf

:!: LDAP

Es müssen ACLs für die neuen Konten definiert werden. Dafür gelten folgende Regeln:

  • Das Konto des Samba Server benötigt Schreibzugriff auf alle Samba Attribute und auf ein paar weitere (z.B. uidNumber, gidNummer…)
  • Das Konto der smbldap-tools benötigen Schreibzugriffe zum Hinzufügen und Löschen von Anwendern-, Gruppen- und Computerkonten.
  • Das Konto des nss_ldap benötigt Schreibzugriffe auf das UNIX Passwort Attribut 1).

Die folgenden Regeln müssen hinter die access to * Regel geschrieben werden.

Einrückungen müssen eingehalten werden!

access to dn.base="" by * read

# users can authenticate and change their password
access to attrs=userPassword,sambaNTPassword,sambaLMPassword,sambaPwdLastSet,sambaPwdMustChange
  by dn="cn=admin,dc=buerovs,dc=intern" write
  by dn="cn=samba,ou=DSA,dc=buerovs,dc=intern" write
  by dn="cn=smbldap-tools,ou=DSA,dc=buerovs,dc=intern" write
  by dn="cn=nssldap,ou=DSA,dc=buerovs,dc=intern" write
  by self write
  by anonymous auth
  by * none

# some attributes need to be readable anonymously so that
# ’id user’ can answer correctly
access to attrs=objectClass,entry,homeDirectory,uid,uidNumber,gidNumber,memberUid
  by dn="cn=samba,ou=DSA,dc=buerovs,dc=intern" write
  by dn="cn=smbldap-tools,ou=DSA,dc=buerovs,dc=intern" write
  by * read

# somme attributes can be writable by users themselves
access to attrs=description,telephoneNumber,roomNumber,homePhone,loginShell,gecos,cn,sn,givenname
  by dn="cn=samba,ou=DSA,dc=buerovs,dc=intern" write
  by dn="cn=smbldap-tools,ou=DSA,dc=buerovs,dc=intern" write
  by self write
  by * read

# some attributes need to be writable for samba
access to attrs=cn,sambaLMPassword,sambaNTPassword,\
sambaPwdLastSet,sambaLogonTime,sambaLogoffTime,\
sambaKickoffTime,sambaPwdCanChange,sambaPwdMustChange,\
sambaAcctFlags,displayName,sambaHomePath,sambaHomeDrive,\
SambaLogonScript,sambaProfilePath,description,\
sambaUserWorkstations,sambaPrimaryGroupSID,sambaDomainName,\
sambaMungedDial,sambaBadPasswordCount,sambaBadPasswordTime,\
sambaPasswordHistory,sambaLogonHours,sambaSID,sambaSIDList,\
sambaTrustFlags,sambaGroupType,sambaNextRid,sambaNextGroupRid,\
sambaNextUserRid,sambaAlgorithmicRidBase,sambaShareName,\
sambaOptionName,sambaBoolOption,sambaIntegerOption,\
sambaStringOption,sambaStringListoption
  by dn="cn=samba,ou=DSA,dc=buerovs,dc=intern" write
  by dn="cn=smbldap-tools,ou=DSA,dc=buerovs,dc=intern" write
  by self read
  by * none

# samba need to be able to create the samba domain account
access to dn.base="dc=buerovs,dc=intern"
  by dn="cn=samba,ou=DSA,dc=buerovs,dc=intern" write
  by dn="cn=smbldap-tools,ou=DSA,dc=buerovs,dc=intern" write
  by * none

# samba need to be able to create new users account
access to dn="ou=Users,dc=buerovs,dc=intern"
  by dn="cn=samba,ou=DSA,dc=buerovs,dc=intern" write
  by dn="cn=smbldap-tools,ou=DSA,dc=buerovs,dc=intern" write
  by * none

# samba need to be able to create new groups account
access to dn="ou=Groups,dc=buerovs,dc=intern"
  by dn="cn=samba,ou=DSA,dc=buerovs,dc=intern" write
  by dn="cn=smbldap-tools,ou=DSA,dc=buerovs,dc=intern" write
  by * none

# samba need to be able to create new computers account
access to dn="ou=Computers,dc=buerovs,dc=intern"
  by dn="cn=samba,ou=DSA,dc=buerovs,dc=intern" write
  by dn="cn=smbldap-tools,ou=DSA,dc=buerovs,dc=intern" write
  by * none

/etc/ldap/slapd.conf -- Änderungen

libnss-ldap.conf

:!: SAMBA

Auch diese Datei muß angepaßt werden:

binddn cn=nssldap,ou=DSA,dc=buerovs,dc=intern
bindpw nssldapsecretpwd # This must be cleartext

/etc/libnss-ldap.conf -- Änderungen

Systemstart

Der LDAP-Server und der Samba Server sind nun fertig eingerichtet. Beide Dienste sollen nochmals neu gestartet werden.

LDAP Account Manager

Dieses Web-Frontend braucht man, um Computer-, Benutzer- und Gruppenkonten in einem LDAP-Verzeichnis zu bearbeiten.

Installation

Der Einfachheit halber, nutzen wir die aktuellen Pakete von Debian. Es ist aber auch kein Problem die tar.gz Pakete von http://lam.sourceforge.net zu laden.

apt-get install ldap-account-manager php4-mcrypt php4-mhash

Konfiguration

:!: LDAP (Aber auch überall anders möglich.)

Damit es mit dem oben abgeänderten LDAP-Server zusammenarbeiten kann, müssen Änderungen vorgenommen werden.

Als erstes ruft man es im Browser auf: http://192.168.0.194/lam/

Man wählt im Browser den Link “LAM configuration“ (oben rechts), dann “Edit server profiles“. Das Standardpasswort heißt „lam“ und ermöglicht den Zugang zur Konfiguration.

Servereinstellungen

Accounttypen und -module

Editieren durch den Button Module editieren

  • Benutzer: inetOrgPerson, posixAccount, sambaSamAccount
  • Gruppen: posixGroup, sambaGroupMapping
  • Hosts: account, posixAccount, sambaSamAccount
  • Samba-Bomänen: sambaDomain

Editieren durch den Button Accounttypen editieren

  • Benutzer LDAP-Suffix: ou=Users,dc=buerovs,dc=intern
  • Gruppen LDAP-Suffix: ou=Groups,dc=buerovs,dc=intern
  • Computer LDAP-Suffix: ou=Computers,dc=buerovs,dc=intern
  • Samba-Domänen LDAP-Suffix: sambaDomainName=BUEROVS,dc=buerovs,dc=intern

UID-Bereiche für Unix-Accounts

  • Minimale Benutzer UID: 10000
  • Maximale Benutzer UID: 30000
  • Minimale Host UID: 50000
  • Maximale Host UID: 60000
  • PasswortHash: CRYPT

Samba 3 Einstellungen

  • Zeitzone: GMT+1

GID-Bereiche für Unix-Gruppen

  • Minimale GID: 10000
  • Maximale GID: 20000

Scripteinstellungen

  • Server mit externem Script: 192.168.0.195
  • Pfad zum externen Script: /usr/local/bin/lamdaemon.pl
  • :!: Diese Angaben sind nur in manchen Fällen notwendig. Sie beschreiben den Ort des Skriptes für das anlegen der Nutzerverzeichnisse (siehe unten).

Sicherheitseinstellungen

  • Liste der berechtigten Nutzer: cn=admin,dc=buerovs,dc=intern
  • Soll der lamdeamon eingerichtet werden, um Home-Verzeichnisse anzulegen und zu löschen, dann muß in der oberen Zeile ein echter Nutzeraccount mit “posixAccount“ und “uid“ hinzugefügt werden: … ;uid=support,ou=Users,dc=buerovs,dc=intern
  • Soll für dieses Profil das Passwort geändert werden, so kann es hier eingegeben werde - andernfalls bleibt dieses leer.

Nun können diese Einstellungen gespeichert werden!

lamdeamon

Dieser Dienst ermöglicht es, daß man über den LAM die Homeverzeichnisse neuer Benutzer einrichten, alter Benutzer löschen und zum Beispiel Quotaeinstellungen vornehmen kann.

Die Versionen des LAM < 1.2.0 haben fehler im lamdaemon

Installation

Auf dem System, auf welchem die Einstellungen ausgeführt werden – also in der Regel auf dem System, auf welchem das Homeverzeichnis liegt – muß der lamdeamon installiert sein.

Diese Datei befindet sich unter /usr/share/ldap-account-manager/lib/lamdaemon.pl und kann von dort kopiert werden.

Auf dem System, auf dem der LAM installiert ist, müssen libssh2 und SSH2 for PHP installiert werden. Da diese nicht im Paketsystem vorhanden sind, muß ein wenig Handarbeit ran.

libssh2

Die Quellpakete findet man hier: http://www.libssh2.org. Man kann sie im Verzeichnis /usr/src ablegen und dort entpacken. Alternativ gibt es das Paket mittlerweile im Unstable Baum von Debian. Dieses läßt sich ohne weiteres auch in etch installieren.

Aus dem Quellcode erstellen

./configure && make all install

Konsole

Paket installieren

dpkg -i libssh2-0_0.14+20070102-1_i386.deb

Konsole

SSH2 für PHP

Auch dieses gibt es nicht als Paket und muß so auf andere Weise beschafft werden. Um pecl nutzen zu können, benötigt man noch das Paket php-pear.

pecl install ssh2-beta

Konsole

Anschließend muß man diese PHP-Erweiterung in der php.ini aktivieren: <file| /etc/php4/apache2/php.ini> ## Zeile 558 extension=ssh2.so </file>

Konfiguration

sudo

Auf dem Zielsystem benötigt der Benutzer Root-Rechte. Dieses ermöglicht man am besten mit sudo.

<file bash| /etc/sudoers> support ALL= NOPASSWD: /usr/local/bin/lamdaemon.pl </file>

Desweiteren muß das Zielsystem mittels PasswordAuthentification per SSH2 erreichbar sein.

slapd.conf

Da der Admin-Benutzer von LDAP bei mir keinen echten UNIX-Account hat, muß der Support-Benutzer Schreibrechte bekommen. Dazu ändert man die erste ACL der slapd.conf fogendermaßen ab:

<file| /etc/ldap/slapd.conf> access to *

      by dn="cn=admin,dc=buerovs,dc=intern" write
      by dn="uid=support,ou=Users,dc=buerovs,dc=intern" write
      by self read
      by * read

</file>

Profile anlegen

Mit Hilfe von Profilen, kann man sich die Arbeit vereinfachen, neue Benutzer, Gruppen usw. anzulegen. Die Profile beinhalten ein Set von Einstellungen, die bei der Erstellung von zum Beispiel Benutzern geladen werden können.

Die Seiten zum Anlegen von Profilen kann man im Bereich “Werkzeuge“ (oben links) und dann ““Profileditor“ erreichen.

Benutzerprofil anlegen

Im Feld “Benutzer“ “Neues Profil erstellen“ aktivieren und “Ok“ klicken.

LDAP

  • LDAP-Suffix: ou=Users,dc=buerovs,dc=intern
  • RDN-Bezeichner: uid

Unix

  • Primäre Gruppe: buerovs
  • Zusätzliche Gruppen: Domain Users, schreiben
  • Heimatverzeichnis: /home/$user
  • Login Shell: /bin/bash

Samba 3

  • Unix-Passwort verwenden: check
  • Kein Passwort setzen: uncheck
  • Account deaktiviert: uncheck
  • Passwort läuft nicht ab: check
  • Ablaufdatum: 1.1.2030
  • Heimatlaufwerk: Z:
  • Heimatverzeichnis: \\LSERVER\$user
  • Anmeldeskript: logon.cmd
  • Samba PCs:
  • Domäne: BUEROVS
  • Windows-Gruppe: Domänenbenutzer
  • Anmeldezeiten:

Profilname: BuerovsStd

Nutzen

Wenn man sich einlogget, dann sind nun zwei Benutzer zu sehen (nobody, root). Beide sind wichtig und dürfen daher nicht gelöscht werden.

Benutzer anlegen

Benutzer –> Neuer Benutzer –> Profil laden BuerovsStdProfil laden

Persönlich

  • Vorname: Support
  • Nachname: Support
  • Alle anderen Felder können beliebig ausgefüllt werden.

Unix

  • Benutzername: support
  • Allgemeiner Name: Support Nutzer
  • UID Nummer: <leer> (Es wird automatisch die nächste freie Nummer gewählt - siehe Konfiguration)
  • Gecos: <leer>
  • Primäre Gruppe: buerovs
  • Zusätzliche Gruppen: “Gruppe ändern“ (Hier können dem Benutzer weitere Unix-Gruppen gegeben werden.)
  • Passwort: “Passwort ändern

Samba 3

  • Einträge müssen nur geändert werden, wenn dieser Benutzer eine Administratorrolle erhalten soll!

Allgemein“ –> “Account erstellen

Gruppe anlegen

UNIX (klicken)

  • Gruppenname: schreiben (muß angegeben werden!)
  • GID Nummer: <leer> (Es wird automatisch die nächste freie Nummer gewählt - siehe Konfiguration)
  • Beschreibung: Zugriff auf alle Dokumente

Samba 3

  • Anzeigename: schreiben

Dann wieder auf “Allgemein“ und “Gruppe anlegen“ klicken.

Bekannte Probleme

  1. Der Benutzername wird auf der Shell nicht angezeigt (I have no name!)

Ressourcen

1) bei Änderung des Passwort mit passwd
computer/howtos/domaincontroller_howto.txt · Zuletzt geändert: 2008/06/02 16:16 von corren
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0