Artikel in Serie "SAMBA4"

SAMBA4 Domain Controller zu existierender W2012R2 AD Domäne hinzufügen

Hinweis: Bei Verwendung der paketierten Version von SAMBA ändern sich die Pfade von /usr/local/samba zu den entsprechenden in /usr und /var.Insbesondere wird der Dienst nicht mit /usr/local/samba/sbin/samba gestartet (bzw. mit samba) sondern mit

systemctl start samba-ad-dc

Szenario

Ich habe eine Windows-Domäne MYDOM.LOCAL mit einem oder mehreren Domain Controllern (DC) mit Windows Server 2012R2 als Betriebssystem.

Ich will einen Domain Controller mit Debian GNU/Linux „jessie/sid“ als Betriebssystem und SAMBA4 hinzufügen.

Ein existierender DC mit W2012R2 hat die IP 192.168.2.5 und heisst WINDC.MYDOM.LOCAL.

Der neue DC mit SAMBA4 hat die IP 192.168.2.6 und soll LINDC.MYDOM.LOCAL heissen.

Weiterlesen … »

Anmeldung von AD-Domänenbenutzern auf Linux mit SSSD und PAM

Szenario

Ich habe (wie in meinem früheren Artikel „SAMBA4 Domain Controller zu existierender W2012R2 AD Domäne hinzufügen“ beschrieben) eine 2008R2 AD Domäne MYDOM.LOCAL mit mindestens einem Domain Controller, LINDC.MYDOM.LOCAL (Debian GNU/Linux „jessie/sid“ mit SAMBA4 aus GIT).

Auf LINDC möchte ich nun auch die Benutzerkonten des Active Directory bei der Anmeldung zur Verfügung stehen haben. Das möchte ich mit dem System Security Services Daemon (SSSD) und Pluggable Authentication Modules (PAM) lösen.

Weiterlesen … »

Active Directory Member Server mit SAMBA4 und PAM-Winbind

Szenario

Ich habe mit Windows Server 2012R2 und SAMBA4 eine Active-Directory-Domäne MYDOM.LOCAL aufgebaut.

Ich möchte mit SAMBA4 einen Dateiserver mit dem Namen LINFS als „Member Server“ zu dieser Domäne hinzufügen. Das Betriebssystem ist Debian GNU/Linux „jessie/sid“; die verwendete Version von SAMBA4 ist 4.1.12.

AD-Domänenbenutzer sollen sich auch per SSH auf LINFS.MYDOM.LOCAL anmelden können, um dort Dateien direkt zu bearbeiten.

Ziel dieses Tutorials soll es sein, einen funktionstüchtigen Server mit SAMBA4 in einer AD-Domäne zu implementieren, auf dem sich AD-Benutzer auch anmelden können, um Dateien direkt zu bearbeiten oder Linux-Anwendungen zu benutzen.

Damit sind die Grundlagen geschaffen, um eine Serverlandschaft für AD-Domänen mit SAMBA4 zu verwirklichen. Spezialprobleme wie Druckerfreigaben, Terminal-Dienste, Netlogon-Skripten, einheitliche Home-Verzeichnisse usw. können danach auf dieser Grundlage behandelt werden.

Weiterlesen … »

AD-Precreation using ktutil, kinit and adcli

Using computer object precreation you can enable machines to join an Active Directory domain with knowledge of just one dedicated one-time-password. Combined with delegation you can offload management of computer objects to an otherwise unprivileged AD user.

Weiterlesen … »

Taking an Online Backup of a SAMBA-4 ActiveDirectory

Notes:

  • The following procedure is available starting with SAMBA version 4.9.
  • The procedure can be performed on a host that is unrelated to the domain, but one domain controller must be reachable, must be used as a nameserver at the time of the backup and have open ports for DNS (53/tcp and /udp) SSH (22/tcp), LDAP (389/tcp), Kerberos (88/tcp and udp) and SMB (445/tcp).

1. On the machine that will be used to perform the backup, if not already present, install SAMBA.

apt -y install samba

2. Get the current smb.conf from the DC you want to query:

scp dc01.ad.example.com:/etc/samba/smb.conf ./smb.conf.dc01

3. Create a backup output directory:

mkdir samba-domain-backup

4. Ensure that /etc/resolv.conf contains the IP address of dc01 as the nameserver.

5. Perform the backup:

samba-tool domain backup online \
    --server=dc01.ad.example.com \
    --configfile=smb.conf.dc01 \
    --realm=AD.EXAMPLE.COM \
    --username=administrator@AD.EXAMPLE.COM \
    --targetdir=samba-domain-backup

Comparing Distinguished LDAP Names

In a Bourne Shell script, a distinguished name (DN) for performing an LDAP-query is held in a variable:

dn="cn=Malmø,ou=County Capitals,dc=Sweden,dc=Europe"

For the purpose of demonstration, this example DN contains a non-ASCII character.

Let’s write a Bourne Shell function that escapes such special characters as requested by RFC 4514 using perl’s Net::LDAP::Util:

canonical_dn() {
    perl -s -MNet::LDAP::Util -e '
        print Net::LDAP::Util::canonical_dn($dn, mbcescape=>1)
    ' -- -dn="$1"
}

Let’s test the function:

echo "Unescaped DN: $dn"
echo "Escaped DN:   $(canonical_dn "$dn")"

The expected output is:

Unescaped DN: cn=Malmø,ou=County Capitals,dc=Sweden,dc=Europe
Escaped DN:   CN=Malm\c3\b8,OU=County Capitals,DC=Sweden,DC=Europe

With a normalized notation, DN values are more robust when sending them to external applications such as the OpenLDAP client tools (ldapsearch & Co.), and certain operations on DNs inside the shellscript itself become a bit more feasible.

But note: For various reasons, DNs can not be reliaby compared for equality, even if both are normalized using canonical_dn. For example, attributes can have a long and a short name, both are valid when denoting a DN, and the OID of an attribute can also be used when denoting a DN. The following DNs address identical entries:

  • cn=Malmø,ou=County Capitals,dc=Sweden,dc=Europe
  • commonName=Malmø,ou=County Capitals,dc=Sweden,dc=Europe
  • 2.5.4.3=Malmø,ou=County Capitals,dc=Sweden,dc=Europe

The information that all these notations of the same attribute commonName are identical is contained in the schema of the LDAP database that is being queried, and neither canonical_dn nor the shellscript can apply this information, this can only be done by an LDAP server.

This made me wonder if there is a canonical way of comparing two DN representations for identity using interaction with an LDAP directory access server. Apparently this is not so:

  • RFC 2251 lists „bind“, „search“, „modify“, „add“, „delete“ and „modify DN“ as supported message types.
  • RFC 2253 makes no mention of DN comparison.
  • I am not aware of an extended request for comparing DNs, at least not one that was widespread across implementations.  ldapwiki.com lists „cancel“, „password modify“, „StartTLS“ and „Who am I“ as known examples, ldap.com additionally lists „Start Transaction“ and „End Transaction“, calling them „standard extended operation types“.