summaryrefslogtreecommitdiffstats
path: root/src/ldapcontroller.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ldapcontroller.cpp')
-rw-r--r--src/ldapcontroller.cpp198
1 files changed, 198 insertions, 0 deletions
diff --git a/src/ldapcontroller.cpp b/src/ldapcontroller.cpp
index 0424bcc..f849d8f 100644
--- a/src/ldapcontroller.cpp
+++ b/src/ldapcontroller.cpp
@@ -24,6 +24,7 @@
#include <pwd.h>
#include <tqlayout.h>
+#include <tqtabwidget.h>
#include <tdelocale.h>
#include <tdeglobal.h>
@@ -54,6 +55,7 @@
#include "primaryrealmwizard/primaryrealmwizard.h"
#include "secondaryrealmwizard/secondaryrealmwizard.h"
#include "processingdialog.h"
+#include "multimasterreplicationconfigdlg.h"
#include "ldapcontrollerconfigbase.h"
@@ -105,6 +107,9 @@ LDAPController::LDAPController(TQWidget *parent, const char *name, const TQStrin
m_base->systemRole->insertItem("Workstation", ROLE_WORKSTATION);
m_base->systemRole->insertItem("Secondary Realm Controller", ROLE_SECONDARY_REALM_CONTROLLER);
m_base->systemRole->insertItem("Primary Realm Controller", ROLE_PRIMARY_REALM_CONTROLLER);
+
+ m_base->multiMasterReplicationMappings->setAllColumnsShowFocus(true);
+ m_base->multiMasterReplicationMappings->setFullWidth(true);
setRootOnlyMsg(i18n("<b>LDAP controller settings take effect system wide, and require administrator access to modify</b><br>To alter the system's realm controller settings, click on the \"Administrator Mode\" button below."));
setUseRootOnlyMsg(true);
@@ -130,6 +135,15 @@ LDAPController::LDAPController(TQWidget *parent, const char *name, const TQStrin
connect(&m_certRefreshTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(updateCertDisplay()));
+ connect(m_base->advancedEnableMultiMasterReplication, TQT_SIGNAL(clicked()), this, TQT_SLOT(changed()));
+
+ connect(m_base->btnAddMultiMasterReplicationMapping, TQT_SIGNAL(clicked()), this, TQT_SLOT(btnAddMultiMasterReplicationMapping()));
+ connect(m_base->btnEditMultiMasterReplicationMapping, TQT_SIGNAL(clicked()), this, TQT_SLOT(btnEditMultiMasterReplicationMapping()));
+ connect(m_base->btnRemoveMultiMasterReplicationMapping, TQT_SIGNAL(clicked()), this, TQT_SLOT(btnRemoveMultiMasterReplicationMapping()));
+
+ connect(m_base->multiMasterReplicationMappings, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(multiMasterReplicationHighlighted()));
+ connect(m_base->multiMasterReplicationMappings, TQT_SIGNAL(executed(TQListViewItem*)), this, TQT_SLOT(modifySelectedMultiMasterReplication()));
+
m_fqdn = LDAPManager::getMachineFQDN();
// FIXME
@@ -310,6 +324,18 @@ void LDAPController::processLockouts() {
canChangeLDAPEnabled = false;
}
+ if (m_base->systemRole->currentItem() == ROLE_PRIMARY_REALM_CONTROLLER) {
+ TQListViewItem* lvi = m_base->multiMasterReplicationMappings->selectedItem();
+ if (lvi) {
+ m_base->btnEditMultiMasterReplicationMapping->setEnabled(true);
+ m_base->btnRemoveMultiMasterReplicationMapping->setEnabled(true);
+ }
+ else {
+ m_base->btnEditMultiMasterReplicationMapping->setEnabled(false);
+ m_base->btnRemoveMultiMasterReplicationMapping->setEnabled(false);
+ }
+ }
+
m_base->systemEnableSupport->setEnabled(canChangeLDAPEnabled);
m_base->systemRole->setEnabled(enabled);
}
@@ -331,6 +357,27 @@ void LDAPController::load() {
}
if (ldapRole == "Primary Realm Controller") {
m_base->systemRole->setCurrentItem(ROLE_PRIMARY_REALM_CONTROLLER);
+
+ // Connect to LDAP
+ TQString realmname = m_defaultRealm.upper();
+ LDAPCredentials* credentials = new LDAPCredentials;
+ credentials->username = "";
+ credentials->password = "";
+ credentials->realm = realmname;
+ LDAPManager* ldap_mgr = new LDAPManager(realmname, "ldapi://", credentials);
+ TQString errorstring;
+
+ // Get replication mappings from LDAP
+ LDAPMasterReplicationInfo replicationsettings = ldap_mgr->getLDAPMasterReplicationSettings(&errorstring);
+ m_base->advancedEnableMultiMasterReplication->setChecked(replicationsettings.enabled);
+ m_base->multiMasterReplicationMappings->clear();
+ LDAPMasterReplicationMap::iterator it;
+ for (it = replicationsettings.serverIDs.begin(); it != replicationsettings.serverIDs.end(); ++it) {
+ new TQListViewItem(m_base->multiMasterReplicationMappings, TQString("%1").arg((*it).id), (*it).fqdn);
+ }
+
+ delete ldap_mgr;
+ delete credentials;
}
else {
m_base->systemRole->setCurrentItem(ROLE_WORKSTATION);
@@ -356,6 +403,10 @@ void LDAPController::load() {
m_defaultRealm = m_systemconfig->readEntry("DefaultRealm");
if (m_base->systemRole->currentItem() == ROLE_PRIMARY_REALM_CONTROLLER) {
+ if (m_base->TabWidget2->indexOf(m_base->advancedPrimaryControllerTab) < 0) {
+ m_base->TabWidget2->insertTab(m_base->advancedPrimaryControllerTab, i18n("Advanced Configuration"));
+ }
+
m_base->groupRealmController->show();
m_base->groupRealmCertificates->show();
@@ -387,6 +438,10 @@ void LDAPController::load() {
m_certRefreshTimer.start(60*1000);
}
else {
+ if (m_base->TabWidget2->indexOf(m_base->advancedPrimaryControllerTab) >= 0) {
+ m_base->TabWidget2->removePage(m_base->advancedPrimaryControllerTab);
+ }
+
m_base->groupRealmController->hide();
m_base->groupRealmCertificates->hide();
@@ -675,11 +730,124 @@ void LDAPController::btnChangeRealmAdminPassword() {
}
}
+void LDAPController::btnAddMultiMasterReplicationMapping() {
+ // Launch a dialog to add the mapping
+ LDAPMasterReplicationMapping mapping;
+
+ bool run = true;
+ MultiMasterReplicationConfigDialog mappingconfigdlg(mapping, m_defaultRealm, this);
+ while (run && (mappingconfigdlg.exec() == TQDialog::Accepted)) {
+ mapping = mappingconfigdlg.m_replicationProperties;
+ // Make sure the provided FQDN and/or UID do not already exist
+ bool conflict = false;
+ TQPtrList<TQListViewItem> lst;
+ TQListViewItemIterator it(m_base->multiMasterReplicationMappings);
+ while (it.current()) {
+ if (it.current()->text(0).toInt() == mapping.id) {
+ conflict = true;
+ KMessageBox::error(0, i18n("<qt>Unable to add new multi-master replication!<p>The provided ID '%1' conflicts with an existing replication mapping.</qt>").arg(mapping.id), i18n("Invalid Configuration"));
+ break;
+ }
+ if (it.current()->text(1) == mapping.fqdn) {
+ conflict = true;
+ KMessageBox::error(0, i18n("<qt>Unable to add new multi-master replication!<p>The provided FQDN '%1' conflicts with an existing replication mapping.</qt>").arg(mapping.fqdn), i18n("Invalid Configuration"));
+ break;
+ }
+ ++it;
+ }
+ if (conflict) {
+ run = true;
+ }
+ else {
+ run = false;
+ new TQListViewItem(m_base->multiMasterReplicationMappings, TQString("%1").arg(mapping.id), mapping.fqdn);
+ changed();
+ }
+ }
+}
+
+void LDAPController::btnEditMultiMasterReplicationMapping() {
+ // Launch a dialog to edit the mapping
+ LDAPMasterReplicationMapping mapping;
+
+ TQListViewItem* lvi = m_base->multiMasterReplicationMappings->selectedItem();
+ if (!lvi) {
+ return;
+ }
+ mapping.id = lvi->text(0).toInt();
+ mapping.fqdn = lvi->text(1);
+
+ bool run = true;
+ MultiMasterReplicationConfigDialog mappingconfigdlg(mapping, m_defaultRealm, this);
+ while (run && (mappingconfigdlg.exec() == TQDialog::Accepted)) {
+ mapping = mappingconfigdlg.m_replicationProperties;
+ // Make sure the provided FQDN and/or UID do not already exist
+ bool conflict = false;
+ TQPtrList<TQListViewItem> lst;
+ TQListViewItemIterator it(m_base->multiMasterReplicationMappings);
+ while (it.current()) {
+ if (it.current() == lvi) {
+ // The selected item will be removed on update, so ignore any conflicts with it...
+ ++it;
+ continue;
+ }
+ if (it.current()->text(0).toInt() == mapping.id) {
+ conflict = true;
+ KMessageBox::error(0, i18n("<qt>Unable to add new multi-master replication!<p>The provided ID '%1' conflicts with an existing replication mapping.</qt>").arg(mapping.id), i18n("Invalid Configuration"));
+ break;
+ }
+ if (it.current()->text(1) == mapping.fqdn) {
+ conflict = true;
+ KMessageBox::error(0, i18n("<qt>Unable to add new multi-master replication!<p>The provided FQDN '%1' conflicts with an existing replication mapping.</qt>").arg(mapping.fqdn), i18n("Invalid Configuration"));
+ break;
+ }
+ ++it;
+ }
+ if (conflict) {
+ run = true;
+ }
+ else {
+ run = false;
+ if (lvi) {
+ delete lvi;
+ }
+ new TQListViewItem(m_base->multiMasterReplicationMappings, TQString("%1").arg(mapping.id), mapping.fqdn);
+ changed();
+ }
+ }
+}
+
+void LDAPController::btnRemoveMultiMasterReplicationMapping() {
+ LDAPMasterReplicationMapping mapping;
+
+ TQListViewItem* lvi = m_base->multiMasterReplicationMappings->selectedItem();
+ if (!lvi) {
+ return;
+ }
+ mapping.id = lvi->text(0).toInt();
+ mapping.fqdn = lvi->text(1);
+
+ if (KMessageBox::warningYesNo(this, i18n("<qt><b>You are about to remove the muli-master replication mapping for '%1'</b><br>This action cannot be undone once committed<p>Are you sure you want to proceed?</qt>").arg(mapping.fqdn), i18n("Confirmation Required")) == KMessageBox::Yes) {
+ delete lvi;
+ changed();
+ }
+}
+
+void LDAPController::multiMasterReplicationHighlighted() {
+ processLockouts();
+}
+
+void LDAPController::modifySelectedMultiMasterReplication() {
+ btnEditMultiMasterReplicationMapping();
+}
+
void LDAPController::defaults() {
//
}
void LDAPController::save() {
+ TQString prevRole = m_systemconfig->readEntry("LDAPRole", "Workstation");
+
m_systemconfig->setGroup(NULL);
m_systemconfig->writeEntry("EnableLDAP", m_base->systemEnableSupport->isChecked());
m_systemconfig->writeEntry("HostFQDN", m_fqdn);
@@ -699,6 +867,36 @@ void LDAPController::save() {
m_systemconfig->sync();
+ // If role was not changed, update any role-specific advanced settings
+ if (prevRole == m_systemconfig->readEntry("LDAPRole", "Workstation")) {
+ if (m_base->systemRole->currentItem() == ROLE_PRIMARY_REALM_CONTROLLER) {
+ TQString realmname = m_defaultRealm.upper();
+ LDAPCredentials* credentials = new LDAPCredentials;
+ credentials->username = "";
+ credentials->password = "";
+ credentials->realm = realmname;
+ LDAPManager* ldap_mgr = new LDAPManager(realmname, "ldapi://", credentials);
+ TQString errorstring;
+
+ // Write multi-master replication settings
+ LDAPMasterReplicationInfo replicationSettings;
+ replicationSettings.enabled = m_base->advancedEnableMultiMasterReplication->isChecked();
+ replicationSettings.serverIDs.clear();
+ TQPtrList<TQListViewItem> lst;
+ TQListViewItemIterator it(m_base->multiMasterReplicationMappings);
+ while (it.current()) {
+ LDAPMasterReplicationMapping mapping;
+ mapping.id = it.current()->text(0).toInt();
+ mapping.fqdn = it.current()->text(1);
+ replicationSettings.serverIDs.append(mapping);
+ ++it;
+ }
+ if (ldap_mgr->setLDAPMasterReplicationSettings(replicationSettings, NULL) != 0) {
+ // ERROR
+ }
+ }
+ }
+
load();
}