Mediawiki an der AD über LDAP

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen

MediaWiki an LDAP (Active Directory) anbinden

Vorbereitung

  • Stelle sicher, dass das PHP LDAP-Modul auf dem Webserver installiert ist: `php-ldap`.
  • Notiere dir die Details des LDAP-Servers:
    • Domain Controller: win2022.lab34.linuggs.de
    • LDAP-Gruppe: lg_wiki
    • Dienstbenutzer: mediawiki
    • Passwort: 123Start$

Installation der MediaWiki LDAP-Extensions

  • Lade die Erweiterungen „LDAPProvider“ und „LDAPAuthentication2“ herunter und installiere sie:
  cd /var/www/html/extensions/
  git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LDAPProvider
  git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LDAPAuthentication2
  git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/PluggableAuth
  git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LDAPAuthorization
  git clone https://gerrit.wikimedia.org/r/mediawiki/extensions//LDAPUserInfo
  • Füge die folgenden Zeilen zur LocalSettings.php hinzu:
# Add more configuration options below.
$wgGroupPermissions['*']['read'] = true;
$wgGroupPermissions['*']['autocreateaccount'] = true;


// === LDAP-Erweiterungen laden ===
wfLoadExtension('LDAPProvider');
wfLoadExtension('PluggableAuth');
wfLoadExtension('LDAPAuthentication2');
wfLoadExtension('LDAPAuthorization');

// === LDAP-Konfiguration festlegen ===
$LDAPProviderDomainConfigs = "/var/www/html/ldap.json"; // Pfad zu ldap.json
$wgLDAPDomainNames = ['lab34.linuggs.de']; // Die Domain, die in ldap.json verwendet wird
$wgPluggableAuth_EnableLocalLogin = true;

// PluggableAuth-Konfiguration
$wgPluggableAuth_Config['lab34.linuggs.de'] = [
    'plugin' => 'LDAPAuthentication2',
    'data' => [
        'domain' => 'lab34.linuggs.de'
    ]
];

// === Debugging aktivieren ===
$wgShowExceptionDetails = true;
$wgDebugLogGroups['LDAP'] = '/var/www/html/LDAP.log';
$wgDebugLogGroups['PluggableAuth'] = '/var/www/html/LDAP.log';
$wgDebugLogGroups['LDAPAuthentication2'] = '/var/www/html/LDAP.log';
$wgDebugLogGroups['LDAPAuthorization'] = '/var/www/html/LDAP.log';

LDAP-Konfiguration in MediaWiki

  • Lege eine Konfigurationsdatei für die LDAP-Anbindung an:
  /var/www/html/extensions/LDAPProvider/ldap.json
  • Füge die Details des LDAP-Servers in der Datei ldap.json hinzu:
  {
      "lab34.linuggs.de": {
          "connection": {
              "server": "ldap://win2022.lab34.linuggs.de",
              "port": 389,
              "enctype": "clear",
              "options": {
                  "LDAP_OPT_DEREF": 1
              },
              "basedn": "dc=lab34,dc=linuggs,dc=de",
              "groupbasedn": "ou=groups,dc=lab34,dc=linuggs,dc=de",
              "userbasedn": "ou=users,dc=lab34,dc=linuggs,dc=de",
              "searchattribute": "sAMAccountName",
              "usernameattribute": "sAMAccountName",
              "realnameattribute": "cn",
              "emailattribute": "mail",
              "userdn": "cn=mediawiki,dc=lab34,dc=linuggs,dc=de",
              "password": "123Start$"
          },
          "authorization": {
              "rules": {
                  "groups": [
                      "CN=lg_wiki,OU=groups,DC=lab34,DC=linuggs,DC=de"
                  ]
              }
          }
      }
  }

Testen der Verbindung

  • Melde dich nach dem Speichern der Änderungen und einem Neustart des Webservers mit einem Benutzer aus der Gruppe lg_wiki an.

Problemlösung

  • Aktiviere das Debugging in der LocalSettings.php für detaillierte Fehlermeldungen:
  $wgShowExceptionDetails = true;
  $wgDebugLogFile = "/var/www/html/logs/debug.log";
  • Überprüfe das Logfile auf Fehler und passe die Konfiguration entsprechend an.