diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-05-18 16:03:27 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-05-18 16:03:27 -0500 |
commit | 37acc91cacd3f5c85e3254fcfd5794fcdcbadc27 (patch) | |
tree | 8a724d562c4bf6b2024340f507f58b1d4cf82af6 /src/ldap.cpp | |
parent | 96936f9f1272296b22c7ed6d6e68e944ba78a6b6 (diff) | |
download | kcmldap-37acc91cacd3f5c85e3254fcfd5794fcdcbadc27.tar.gz kcmldap-37acc91cacd3f5c85e3254fcfd5794fcdcbadc27.zip |
Can now add/remove realms to TDE config file
Diffstat (limited to 'src/ldap.cpp')
-rw-r--r-- | src/ldap.cpp | 68 |
1 files changed, 58 insertions, 10 deletions
diff --git a/src/ldap.cpp b/src/ldap.cpp index 861ed40..a3afbbf 100644 --- a/src/ldap.cpp +++ b/src/ldap.cpp @@ -64,14 +64,17 @@ LDAPConfig::LDAPConfig(TQWidget *parent, const char *name, const TQStringList&) base = new LDAPConfigBase(this); layout->add(base); + base->ldapRealmList->setAllColumnsShowFocus(true); setRootOnlyMsg(i18n("<b>Bonded LDAP realms take effect system wide, and require administrator access to modify</b><br>To alter the system's bonded LDAP realms, click on the \"Administrator Mode\" button below.")); setUseRootOnlyMsg(true); - connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), TQT_SLOT(changed())); - connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), TQT_SLOT(processLockouts())); + connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), this, TQT_SLOT(changed())); + connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), this, TQT_SLOT(processLockouts())); + connect(base->ldapRealmList, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(processLockouts())); connect(base->btnBondRealm, TQT_SIGNAL(clicked()), TQT_SLOT(bondToNewRealm())); + connect(base->btnRemoveRealm, TQT_SIGNAL(clicked()), TQT_SLOT(removeRealm())); load(); @@ -102,12 +105,13 @@ void LDAPConfig::load(bool useDefaults ) base->systemEnableSupport->setChecked(systemconfig->readBoolEntry("EnableLDAP", false)); // Load realms + m_realms.clear(); TQStringList cfgRealms = systemconfig->groupList(); for (TQStringList::Iterator it(cfgRealms.begin()); it != cfgRealms.end(); ++it) { if ((*it).startsWith("LDAPRealm-")) { systemconfig->setGroup(*it); TQString realmName=*it; - realmName.remove(strlen("LDAPRealm-")); + realmName.remove(0,strlen("LDAPRealm-")); if (!m_realms.contains(realmName)) { // Read in realm data LDAPRealmConfig realmcfg; @@ -124,18 +128,28 @@ void LDAPConfig::load(bool useDefaults ) realmcfg.pkinit_require_krbtgt_otherName = systemconfig->readBoolEntry("pkinit_require_krbtgt_otherName"); realmcfg.win2k_pkinit = systemconfig->readBoolEntry("win2k_pkinit"); realmcfg.win2k_pkinit_require_binding = systemconfig->readBoolEntry("win2k_pkinit_require_binding"); - // Add realm to lists + // Add realm to list m_realms.insert(realmName, realmcfg); - (void)new TQListViewItem(base->ldapRealmList, ((realmcfg.bonded)?i18n("Bonded"):i18n("Deactivated")), realmName); } } } + updateRealmList(); + processLockouts(); emit changed(useDefaults); } +void LDAPConfig::updateRealmList() { + base->ldapRealmList->clear(); + LDAPRealmConfigList::Iterator it; + for (it = m_realms.begin(); it != m_realms.end(); ++it) { + LDAPRealmConfig realmcfg = it.data(); + (void)new TQListViewItem(base->ldapRealmList, ((realmcfg.bonded)?i18n("Bonded"):i18n("Deactivated")), realmcfg.name); + } +} + void LDAPConfig::defaults() { } @@ -165,6 +179,23 @@ void LDAPConfig::save() { systemconfig->writeEntry("win2k_pkinit", realmcfg.win2k_pkinit); systemconfig->writeEntry("win2k_pkinit_require_binding", realmcfg.win2k_pkinit_require_binding); } + + // Delete any realms that do not exist in the m_realms database + TQStringList cfgRealms = systemconfig->groupList(); + for (TQStringList::Iterator it(cfgRealms.begin()); it != cfgRealms.end(); ++it) { + if ((*it).startsWith("LDAPRealm-")) { + systemconfig->setGroup(*it); + TQString realmName=*it; + realmName.remove(0,strlen("LDAPRealm-")); + if (!m_realms.contains(realmName)) { + systemconfig->deleteGroup(*it); + } + } + } + + systemconfig->sync(); + + load(); } void LDAPConfig::processLockouts() { @@ -174,11 +205,19 @@ void LDAPConfig::processLockouts() { TQListViewItem *selrealm = base->ldapRealmList->selectedItem(); if (selrealm) { + LDAPRealmConfig realmcfg = m_realms[selrealm->text(1)]; base->btnBondRealm->setEnabled(true); base->btnReBondRealm->setEnabled(true); - base->btnDeactivateRealm->setEnabled(true); // RAJA FIXME only if realm is bonded - base->btnRemoveRealm->setEnabled(true); // RAJA FIXME only if realm is not bonded - base->btnRealmProperties->setEnabled(true); // RAJA FIXME only if realm is not bonded + if (realmcfg.bonded) { + base->btnDeactivateRealm->setEnabled(true); + base->btnRemoveRealm->setEnabled(false); + base->btnRealmProperties->setEnabled(false); + } + else { + base->btnDeactivateRealm->setEnabled(false); + base->btnRemoveRealm->setEnabled(true); + base->btnRealmProperties->setEnabled(true); + } } else { base->btnBondRealm->setEnabled(true); @@ -195,13 +234,22 @@ void LDAPConfig::bondToNewRealm() { // Something will probably change save(); - BondWizard *bondwizard = new BondWizard(this); - bondwizard->exec(); + BondWizard bondwizard(&m_realms, this, this); + bondwizard.exec(); // Something probably changed load(); } +void LDAPConfig::removeRealm() { + TQListViewItem *selrealm = base->ldapRealmList->selectedItem(); + if (selrealm) { + m_realms.remove(selrealm->text(1)); + updateRealmList(); + changed(); + } +} + int LDAPConfig::buttons() { return KCModule::Apply|KCModule::Help; } |