summaryrefslogtreecommitdiffstats
path: root/src/ldapcontroller.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2012-06-01 02:39:31 -0500
committerTimothy Pearson <[email protected]>2012-06-01 02:39:31 -0500
commit28941371305de0bdbcc43e30d8c404953d047591 (patch)
tree4b6bb2ca8cce0b096c7156ef731241c27335c1ef /src/ldapcontroller.cpp
parent46d1d860d1ae8c455f19b4fd125eba4e0268022a (diff)
downloadkcmldapcontroller-28941371305de0bdbcc43e30d8c404953d047591.tar.gz
kcmldapcontroller-28941371305de0bdbcc43e30d8c404953d047591.zip
Additional GUI work, now ready for deployment process
Diffstat (limited to 'src/ldapcontroller.cpp')
-rw-r--r--src/ldapcontroller.cpp62
1 files changed, 60 insertions, 2 deletions
diff --git a/src/ldapcontroller.cpp b/src/ldapcontroller.cpp
index a774263..ba7f5de 100644
--- a/src/ldapcontroller.cpp
+++ b/src/ldapcontroller.cpp
@@ -18,6 +18,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
#include <tqlayout.h>
#include <klocale.h>
@@ -39,6 +43,7 @@
#include "ldapcontroller.h"
#include "realmwizard.h"
+#include "processingdialog.h"
// FIXME
// Connect this to CMake/Automake
@@ -80,6 +85,8 @@ LDAPController::LDAPController(TQWidget *parent, const char *name, const TQStrin
connect(m_base->systemEnableSupport, TQT_SIGNAL(clicked()), this, TQT_SLOT(processLockouts()));
connect(m_base->systemRole, TQT_SIGNAL(activated(const TQString&)), this, TQT_SLOT(systemRoleChanged()));
+ m_fqdn = getMachineFQDN();
+
load();
if (getuid() != 0 || !m_systemconfig->checkConfigFilesWritable( true )) {
@@ -92,6 +99,33 @@ LDAPController::LDAPController(TQWidget *parent, const char *name, const TQStrin
LDAPController::~LDAPController() {
}
+// FIXME
+// This should be moved to a TDE core library
+TQString LDAPController::getMachineFQDN() {
+ struct addrinfo hints, *info, *p;
+ int gai_result;
+
+ char hostname[1024];
+ hostname[1023] = '\0';
+ gethostname(hostname, 1023);
+
+ memset(&hints, 0, sizeof hints);
+ hints.ai_family = AF_UNSPEC; // IPV4 or IPV6
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_CANONNAME;
+
+ if ((gai_result = getaddrinfo(hostname, NULL, &hints, &info)) != 0) {
+ return TQString(hostname);
+ }
+ TQString fqdn = TQString(hostname);
+ for (p=info; p!=NULL; p=p->ai_next) {
+ fqdn = TQString(p->ai_canonname);
+ }
+ freeaddrinfo(info);
+
+ return fqdn;
+}
+
void LDAPController::systemRoleChanged() {
if (m_base->systemRole->currentItem() != m_prevRole) {
if (m_base->systemRole->currentItem() == ROLE_REALM_CONTROLLER) {
@@ -115,7 +149,7 @@ void LDAPController::systemRoleChanged() {
// Something will probably change
save();
- RealmWizard realmwizard(this, this);
+ RealmWizard realmwizard(this, m_fqdn, this);
if (realmwizard.exec() < 0) {
// Wizard was cancelled
// Back out all changes!
@@ -139,10 +173,21 @@ void LDAPController::processLockouts() {
m_base->systemRole->setEnabled(enabled);
}
-void LDAPController::load() {
+void LDAPController::load() {
+ bool thisIsMyMachine;
+
m_systemconfig->setGroup(NULL);
m_base->systemEnableSupport->setChecked(m_systemconfig->readBoolEntry("EnableLDAP", false));
+ if (m_fqdn == m_systemconfig->readEntry("HostFQDN", "")) {
+ thisIsMyMachine = true;
+ }
+ else {
+ thisIsMyMachine = false;
+ }
TQString ldapRole = m_systemconfig->readEntry("LDAPRole", "Workstation");
+ if (!thisIsMyMachine) {
+ ldapRole = "Workstation";
+ }
if (ldapRole == "Realm Controller") {
m_base->systemRole->setCurrentItem(ROLE_REALM_CONTROLLER);
}
@@ -179,6 +224,19 @@ void LDAPController::save() {
load();
}
+int LDAPController::createNewLDAPRealm(TQWidget* dialogparent, LDAPRealmConfig realmconfig, TQString adminUserName, const char * adminPassword, TQString adminRealm, TQString *errstr) {
+ ProcessingDialog pdialog(dialogparent);
+ pdialog.setStatusMessage(i18n("Loading data for realm deployment..."));
+ pdialog.raise();
+ pdialog.setActiveWindow();
+tqApp->processEvents();
+sleep(1);
+tqApp->processEvents();
+sleep(5);
+ // RAJA FIXME
+ pdialog.closeDialog();
+}
+
int LDAPController::buttons() {
return KCModule::Apply|KCModule::Help;
}