diff --git a/src/Makefile.am b/src/Makefile.am index 713e114..556ceee 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,7 +4,7 @@ METASOURCES = AUTO # Install this plugin in the KDE modules directory kde_module_LTLIBRARIES = kcm_ldapmanager.la -kcm_ldapmanager_la_SOURCES = ldapmgr.cpp ldapconfigbase.ui userconfigbase.ui groupconfigbase.ui userconfigdlg.cpp groupconfigdlg.cpp +kcm_ldapmanager_la_SOURCES = ldapmgr.cpp ldapconfigbase.ui userconfigbase.ui groupconfigbase.ui serviceconfigbase.ui userconfigdlg.cpp groupconfigdlg.cpp serviceconfigdlg.cpp kcm_ldapmanager_la_LIBADD = -lkio $(LIB_TDEUI) -lldap -ltdeldap kcm_ldapmanager_la_LDFLAGS = -avoid-version -module -no-undefined \ $(all_libraries) diff --git a/src/ldapconfigbase.ui b/src/ldapconfigbase.ui index 9c0be29..fb521d4 100644 --- a/src/ldapconfigbase.ui +++ b/src/ldapconfigbase.ui @@ -672,6 +672,198 @@ + + + servicesTab + + + Services + + + + unnamed + + + + service_icon + + + + + unnamed + + + Services in LDAP Realm + + + + + service_ldapRealm + + + + + Spacer3 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + splitter1 + + + Vertical + + + + + Service Name + + + true + + + true + + + + + Machine Name + + + true + + + true + + + + service_list + + + false + + + + + unnamed_layoutwidget3 + + + + 0 + + + + serviceControls + + + + unnamed + + + + service_buttonModify + + + Modify + + + + + service_buttonAdd + + + New + + + + + service_buttonDelete + + + Delete + + + + + + + groupServiceDetails + + + Details + + + + unnamed + + + + unnamed + + + Service Name: + + + + + service_name + + + false + + + + + unnamed + + + Author: + + + + + service_author + + + false + + + + + + + Spacer6 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + diff --git a/src/ldapmgr.cpp b/src/ldapmgr.cpp index a7f0993..36224e6 100644 --- a/src/ldapmgr.cpp +++ b/src/ldapmgr.cpp @@ -48,6 +48,7 @@ #include "ldappasswddlg.h" #include "userconfigdlg.h" #include "groupconfigdlg.h" +#include "serviceconfigdlg.h" // FIXME // Connect this to CMake/Automake @@ -74,6 +75,8 @@ LDAPConfig::LDAPConfig(TQWidget *parent, const char *name, const TQStringList&) base->group_memberList->setFullWidth(true); base->machine_list->setAllColumnsShowFocus(true); base->machine_list->setFullWidth(true); + base->service_list->setAllColumnsShowFocus(true); + base->service_list->setFullWidth(true); base->user_loginName->setEnabled(false); base->user_uid->setEnabled(false); @@ -84,27 +87,34 @@ LDAPConfig::LDAPConfig(TQWidget *parent, const char *name, const TQStringList&) base->machine_name->setEnabled(false); base->machine_author->setEnabled(false); + base->service_name->setEnabled(false); + base->service_author->setEnabled(false); base->user_icon->setPixmap(SmallIcon("personal.png")); base->group_icon->setPixmap(SmallIcon("kdmconfig.png")); base->machine_icon->setPixmap(SmallIcon("system.png")); + base->service_icon->setPixmap(SmallIcon("kcmsystem.png")); connect(base->user_ldapRealm, TQT_SIGNAL(activated(const TQString&)), this, TQT_SLOT(connectToRealm(const TQString&))); connect(base->group_ldapRealm, TQT_SIGNAL(activated(const TQString&)), this, TQT_SLOT(connectToRealm(const TQString&))); connect(base->machine_ldapRealm, TQT_SIGNAL(activated(const TQString&)), this, TQT_SLOT(connectToRealm(const TQString&))); + connect(base->service_ldapRealm, TQT_SIGNAL(activated(const TQString&)), this, TQT_SLOT(connectToRealm(const TQString&))); connect(base->user_list, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(userHighlighted())); connect(base->group_list, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(groupHighlighted())); connect(base->machine_list, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(machineHighlighted())); + connect(base->service_list, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(serviceHighlighted())); connect(base->user_list, TQT_SIGNAL(executed(TQListViewItem*)), this, TQT_SLOT(modifySelectedUser())); connect(base->group_list, TQT_SIGNAL(executed(TQListViewItem*)), this, TQT_SLOT(modifySelectedGroup())); connect(base->user_buttonAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(addNewUser())); connect(base->group_buttonAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(addNewGroup())); + connect(base->service_buttonAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(addNewService())); connect(base->user_buttonModify, TQT_SIGNAL(clicked()), this, TQT_SLOT(modifySelectedUser())); connect(base->group_buttonModify, TQT_SIGNAL(clicked()), this, TQT_SLOT(modifySelectedGroup())); connect(base->user_buttonDelete, TQT_SIGNAL(clicked()), this, TQT_SLOT(removeSelectedUser())); connect(base->group_buttonDelete, TQT_SIGNAL(clicked()), this, TQT_SLOT(removeSelectedGroup())); connect(base->machine_buttonDelete, TQT_SIGNAL(clicked()), this, TQT_SLOT(removeSelectedMachine())); + connect(base->service_buttonDelete, TQT_SIGNAL(clicked()), this, TQT_SLOT(removeSelectedService())); load(); @@ -129,9 +139,11 @@ void LDAPConfig::load() { base->user_ldapRealm->clear(); base->group_ldapRealm->clear(); base->machine_ldapRealm->clear(); + base->service_ldapRealm->clear(); base->user_ldapRealm->insertItem(""); base->group_ldapRealm->insertItem(""); base->machine_ldapRealm->insertItem(""); + base->service_ldapRealm->insertItem(""); TQStringList cfgRealms = m_systemconfig->groupList(); for (TQStringList::Iterator it(cfgRealms.begin()); it != cfgRealms.end(); ++it) { if ((*it).startsWith("LDAPRealm-")) { @@ -141,6 +153,7 @@ void LDAPConfig::load() { base->user_ldapRealm->insertItem(realmName); base->group_ldapRealm->insertItem(realmName); base->machine_ldapRealm->insertItem(realmName); + base->service_ldapRealm->insertItem(realmName); } } TQString defaultRealm = m_systemconfig->readEntry("DefaultRealm", TQString::null); @@ -150,6 +163,7 @@ void LDAPConfig::load() { base->user_ldapRealm->setCurrentItem(i); base->group_ldapRealm->setCurrentItem(i); base->machine_ldapRealm->setCurrentItem(i); + base->service_ldapRealm->setCurrentItem(i); break; } } @@ -204,6 +218,19 @@ void LDAPConfig::processLockouts() { // Think about it...yes you can add the 'add' feature...kadmin 'ank --random-key host/HOSTNAME.FQDN'... base->machine_buttonAdd->setEnabled(false); base->machine_buttonModify->setEnabled(false); + + lvi = base->service_list->selectedItem(); + if (lvi) { + LDAPServiceInfo service = selectedService(); + base->service_buttonDelete->setEnabled(!service.tde_builtin_account); + } + else { + base->service_buttonDelete->setEnabled(false); + } + base->service_buttonAdd->setEnabled(true); + // FIXME + // Disable service modify as it is not implemented + base->service_buttonModify->setEnabled(false); } void LDAPConfig::connectToRealm(const TQString& realm) { @@ -211,6 +238,7 @@ void LDAPConfig::connectToRealm(const TQString& realm) { base->user_ldapRealm->setCurrentItem(realm, false, -1); base->group_ldapRealm->setCurrentItem(realm, false, -1); base->machine_ldapRealm->setCurrentItem(realm, false, -1); + base->service_ldapRealm->setCurrentItem(realm, false, -1); if (realm == "") { abortConnection(); @@ -237,9 +265,11 @@ void LDAPConfig::abortConnection() { base->user_list->clear(); base->group_list->clear(); base->machine_list->clear(); + base->service_list->clear(); base->user_ldapRealm->setCurrentItem("", false, -1); base->group_ldapRealm->setCurrentItem("", false, -1); base->machine_ldapRealm->setCurrentItem("", false, -1); + base->service_ldapRealm->setCurrentItem("", false, -1); } void LDAPConfig::updateAllInformation() { @@ -257,12 +287,19 @@ void LDAPConfig::updateAllInformation() { abortConnection(); return; } + else { + if (populateServices() != 0) { + abortConnection(); + return; + } + } } } updateUsersList(); updateGroupsList(); updateMachinesList(); + updateServicesList(); } int LDAPConfig::populateUsers() { @@ -283,6 +320,12 @@ int LDAPConfig::populateMachines() { return retcode; } +int LDAPConfig::populateServices() { + int retcode; + m_serviceInfoList = m_ldapmanager->services(&retcode); + return retcode; +} + void LDAPConfig::updateUsersList() { TQListViewItem* itm = base->user_list->selectedItem(); TQString prevSelectedItemText; @@ -347,6 +390,27 @@ void LDAPConfig::updateMachinesList() { processLockouts(); } +void LDAPConfig::updateServicesList() { + TQListViewItem* itm = base->service_list->selectedItem(); + TQString prevSelectedItemText; + if (itm) { + prevSelectedItemText = itm->text(0); + } + + base->service_list->clear(); + LDAPServiceInfoList::Iterator it; + for (it = m_serviceInfoList.begin(); it != m_serviceInfoList.end(); ++it) { + LDAPServiceInfo service = *it; + itm = new TQListViewItem(base->service_list, service.name, service.machine); + if (prevSelectedItemText != "") { + if (service.name == prevSelectedItemText) { + base->service_list->setSelected(itm, true); + } + } + } + processLockouts(); +} + LDAPUserInfo LDAPConfig::findUserInfoByName(TQString name) { // Figure out which user is selected LDAPUserInfoList::Iterator it; @@ -383,6 +447,18 @@ LDAPMachineInfo LDAPConfig::findMachineInfoByName(TQString name) { return LDAPMachineInfo(); } +LDAPServiceInfo LDAPConfig::findServiceInfoByName(TQString name, TQString machine) { + // Figure out which service is selected + LDAPServiceInfoList::Iterator it; + for (it = m_serviceInfoList.begin(); it != m_serviceInfoList.end(); ++it) { + LDAPServiceInfo service = *it; + if ((service.name == name) && (service.machine == machine)) { + return service; + } + } + return LDAPServiceInfo(); +} + LDAPUserInfo LDAPConfig::findUserInfoByNameAndUID(TQString name, TQString uid) { // Figure out which user is selected LDAPUserInfoList::Iterator it; @@ -443,6 +519,14 @@ LDAPMachineInfo LDAPConfig::selectedMachine() { return findMachineInfoByName(lvi->text(0)); } +LDAPServiceInfo LDAPConfig::selectedService() { + TQListViewItem* lvi = base->service_list->selectedItem(); + if (!lvi) { + return LDAPServiceInfo(); + } + return findServiceInfoByName(lvi->text(0), lvi->text(1)); +} + LDAPUserInfo LDAPConfig::findUserByDistinguishedName(TQString dn) { LDAPUserInfoList::Iterator it; for (it = m_userInfoList.begin(); it != m_userInfoList.end(); ++it) { @@ -476,6 +560,10 @@ LDAPGroupInfoList LDAPConfig::groupList() { return m_groupInfoList; } +LDAPMachineInfoList LDAPConfig::machineList() { + return m_machineInfoList; +} + void LDAPConfig::userHighlighted() { // Show information in the quick view area LDAPUserInfo user = selectedUser(); @@ -524,6 +612,16 @@ void LDAPConfig::machineHighlighted() { processLockouts(); } +void LDAPConfig::serviceHighlighted() { + // Show information in the quick view area + LDAPServiceInfo service = selectedService(); + + base->service_name->setText(service.name); + base->service_author->setText(findUserByDistinguishedName(service.creatorsName).name); + + processLockouts(); +} + void LDAPConfig::addNewUser() { // Launch a dialog to add the user LDAPUserInfo user; @@ -636,6 +734,21 @@ void LDAPConfig::addNewGroup() { updateAllInformation(); } +void LDAPConfig::addNewService() { + // Launch a dialog to add the service + LDAPServiceInfo service; + + ServiceConfigDialog serviceconfigdlg(service, this); + if (serviceconfigdlg.exec() == TQDialog::Accepted) { + service = serviceconfigdlg.m_service; + TQString errorstring; + if (m_ldapmanager->addServiceInfo(service, &errorstring) != 0) { + KMessageBox::error(0, i18n("Unable to add new service!

%1").arg(errorstring), i18n("Internal Failure")); + } + } + updateAllInformation(); +} + void LDAPConfig::modifySelectedUser() { // Launch a dialog to edit the user LDAPUserInfo user = selectedUser(); @@ -724,6 +837,16 @@ void LDAPConfig::removeSelectedMachine() { updateAllInformation(); } +void LDAPConfig::removeSelectedService() { + LDAPServiceInfo service = selectedService(); + + if (KMessageBox::warningYesNo(this, i18n("You are about to delete the service %1 for host %2
This action cannot be undone

Are you sure you want to proceed?").arg(service.name).arg(service.machine), i18n("Confirmation Required")) == KMessageBox::Yes) { + m_ldapmanager->deleteServiceInfo(service); + } + + updateAllInformation(); +} + TQString readFullLineFromPtyProcess(PtyProcess* proc) { TQString result = ""; while ((!result.contains("\n")) && (!result.contains(":")) && (!result.contains(">"))) { diff --git a/src/ldapmgr.h b/src/ldapmgr.h index 7d38c6e..f28befe 100644 --- a/src/ldapmgr.h +++ b/src/ldapmgr.h @@ -56,19 +56,24 @@ class LDAPConfig: public KCModule int populateUsers(); int populateGroups(); int populateMachines(); + int populateServices(); void updateUsersList(); void updateGroupsList(); void updateMachinesList(); + void updateServicesList(); void userHighlighted(); void groupHighlighted(); void machineHighlighted(); + void serviceHighlighted(); void addNewUser(); void addNewGroup(); + void addNewService(); void modifySelectedUser(); void modifySelectedGroup(); void removeSelectedUser(); void removeSelectedGroup(); void removeSelectedMachine(); + void removeSelectedService(); void updateAllInformation(); void abortConnection(); @@ -76,6 +81,7 @@ class LDAPConfig: public KCModule LDAPUserInfo findUserInfoByName(TQString name); LDAPGroupInfo findGroupInfoByName(TQString name); LDAPMachineInfo findMachineInfoByName(TQString name); + LDAPServiceInfo findServiceInfoByName(TQString name, TQString machine); LDAPUserInfo findUserInfoByNameAndUID(TQString name, TQString uid); LDAPGroupInfo findGroupInfoByNameAndGID(TQString name, TQString gid); LDAPGroupInfo findGroupInfoByGID(TQString gid); @@ -83,11 +89,13 @@ class LDAPConfig: public KCModule LDAPGroupInfoList findGroupsForUserByDistinguishedName(TQString dn); LDAPUserInfoList userList(); LDAPGroupInfoList groupList(); + LDAPMachineInfoList machineList(); private: LDAPUserInfo selectedUser(); LDAPGroupInfo selectedGroup(); LDAPMachineInfo selectedMachine(); + LDAPServiceInfo selectedService(); int setPasswordForUser(LDAPUserInfo user, TQString *errstr); private: @@ -100,6 +108,7 @@ class LDAPConfig: public KCModule LDAPUserInfoList m_userInfoList; LDAPGroupInfoList m_groupInfoList; LDAPMachineInfoList m_machineInfoList; + LDAPServiceInfoList m_serviceInfoList; }; #endif diff --git a/src/serviceconfigbase.ui b/src/serviceconfigbase.ui new file mode 100644 index 0000000..c7cd2bf --- /dev/null +++ b/src/serviceconfigbase.ui @@ -0,0 +1,89 @@ + + LDAPServiceConfigBase + + + LDAPServiceConfigBase + + + + 0 + 0 + 519 + 356 + + + + + unnamed + + + + TabWidget2 + + + true + + + + detailsTab + + + Kerberos Service + + + + unnamed + + + + detailsIcon + + + + 4 + 5 + 1 + 0 + + + + + + unnamed + + + Service Name + + + + + serviceName + + + + + unnamed + + + Host Machine + + + + + hostMachine + + + + + + + + + LDAPServiceConfigBase.ui.h + + + kdialog.h + + + + \ No newline at end of file diff --git a/src/serviceconfigdlg.cpp b/src/serviceconfigdlg.cpp new file mode 100644 index 0000000..cd5eaae --- /dev/null +++ b/src/serviceconfigdlg.cpp @@ -0,0 +1,98 @@ +/*************************************************************************** + * Copyright (C) 2012 by Timothy Pearson * + * kb9vqf@pearsoncomputing.net * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ldapmgr.h" +#include "serviceconfigdlg.h" + +ServiceConfigDialog::ServiceConfigDialog(LDAPServiceInfo service, LDAPConfig* parent, const char* name) + : KDialogBase(parent, name, true, i18n("LDAP Service Properties"), Ok|Cancel, Ok, true), m_service(service), m_ldapconfig(parent) +{ + int i; + + m_base = new LDAPServiceConfigBase(this); + setMainWidget(m_base); + + // Populate machine list + LDAPMachineInfoList machineList = m_ldapconfig->machineList(); + LDAPMachineInfoList::Iterator it; + for (it = machineList.begin(); it != machineList.end(); ++it) { + LDAPMachineInfo machine = *it; + m_base->hostMachine->insertItem(machine.name, -1); + } + + m_base->detailsIcon->setPixmap(SmallIcon("kcmsystem.png")); + + connect(m_base->serviceName, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(processLockouts())); + + // Update fields + m_base->serviceName->setText(m_service.name); + for (i=0; ihostMachine->count(); i++) { + if (m_base->hostMachine->text(i).lower() == m_service.machine.lower()) { + m_base->hostMachine->setCurrentItem(i); + } + } + + m_base->serviceName->setFocus(); + + processLockouts(); +} + +void ServiceConfigDialog::slotOk() { + // Special handler for new service + if (m_service.distinguishedName == "") { + m_service.name = m_base->serviceName->text(); + m_service.machine = m_base->hostMachine->currentText(); + } + + accept(); +} + +void ServiceConfigDialog::processLockouts() { + // Special handler for new group + if ((m_service.distinguishedName == "") && (m_base->serviceName->text() == "")) { + enableButton(KDialogBase::Ok, false); + } + else { + enableButton(KDialogBase::Ok, true); + } +} + +LDAPServiceInfo ServiceConfigDialog::serviceProperties() { + return m_service; +} + +#include "serviceconfigdlg.moc" diff --git a/src/serviceconfigdlg.h b/src/serviceconfigdlg.h new file mode 100644 index 0000000..5ebf5a1 --- /dev/null +++ b/src/serviceconfigdlg.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * Copyright (C) 2012 by Timothy Pearson * + * kb9vqf@pearsoncomputing.net * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _SERVICECONFIGDIALOG_H_ +#define _SERVICECONFIGDIALOG_H_ + +#include + +#include "libtdeldap.h" +#include "serviceconfigbase.h" + +class ServiceConfigDialog : public KDialogBase +{ + Q_OBJECT + +public: + ServiceConfigDialog(LDAPServiceInfo service, LDAPConfig* parent = 0, const char* name = 0); + LDAPServiceInfo serviceProperties(); + +public slots: + void slotOk(); + void processLockouts(); + +public: + LDAPServiceConfigBase *m_base; + LDAPServiceInfo m_service; + +private: + LDAPConfig* m_ldapconfig; +}; + +#endif // _SERVICECONFIGDIALOG_H_