1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
/***************************************************************************
* Copyright (C) 2012 by Timothy Pearson *
* [email protected] *
* *
* 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 <klocale.h>
#include <klineedit.h>
#include <ktextedit.h>
#include <knuminput.h>
#include <kactionselector.h>
#include <tqlistbox.h>
#include <kpushbutton.h>
#include <tqpixmap.h>
#include <tqiconset.h>
#include <tqlabel.h>
#include <kurlrequester.h>
#include <kcombobox.h>
#include <tqradiobutton.h>
#include <tqcheckbox.h>
#include <kdatetimewidget.h>
#include "ldapmgr.h"
#include "userconfigdlg.h"
UserConfigDialog::UserConfigDialog(LDAPUserInfo user, LDAPConfig* parent, const char* name)
: KDialogBase(parent, name, true, i18n("LDAP User Properties"), Ok|Cancel, Ok, true), m_user(user), m_ldapconfig(parent)
{
m_base = new LDAPUserConfigBase(this);
setMainWidget(m_base);
TQStringList availableShells = TQStringList::split(" ", AVAILABLE_SHELLS);
for ( TQStringList::Iterator it = availableShells.begin(); it != availableShells.end(); ++it ) {
m_base->shell->insertItem(*it, -1);
}
if (user.distinguishedName != "") {
m_base->loginName->setEnabled(false);
}
m_base->lastChanged->setEnabled(false);
connect(m_base->loginName, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(processLockouts()));
connect(m_base->passwordExpireEnabled, TQT_SIGNAL(clicked()), this, TQT_SLOT(processLockouts()));
connect(m_base->passwordExpireDisabled, TQT_SIGNAL(clicked()), this, TQT_SLOT(processLockouts()));
connect(m_base->requirePasswordAging, TQT_SIGNAL(clicked()), this, TQT_SLOT(processLockouts()));
connect(m_base->requirePasswordMinAge, TQT_SIGNAL(clicked()), this, TQT_SLOT(processLockouts()));
connect(m_base->primaryGroup, TQT_SIGNAL(activated(const TQString&)), this, TQT_SLOT(processLockouts()));
// Update fields
// KPasswordEdit* passwordEntry;
if (m_user.status == KRB5_DISABLED_ACCOUNT) {
m_base->userStatusEnabled->setChecked(false);
m_base->userStatusDisabled->setChecked(true);
}
else {
m_base->userStatusEnabled->setChecked(true);
m_base->userStatusDisabled->setChecked(false);
}
m_base->loginName->setText(m_user.name);
m_base->realName->setText(m_user.commonName);
m_base->UID->setValue(m_user.uid);
LDAPGroupInfoList groupList = m_ldapconfig->groupList();
LDAPGroupInfoList::Iterator it;
for (it = groupList.begin(); it != groupList.end(); ++it) {
m_base->primaryGroup->insertItem((*it).name, -1);
}
m_base->primaryGroup->setCurrentItem(m_ldapconfig->findGroupInfoByGID(TQString("%1").arg(m_user.primary_gid)).name, false, -1);
m_prevPrimaryGroup = m_base->primaryGroup->currentText();
m_base->homeDirectory->setURL(m_user.homedir);
m_base->shell->setEditText(m_user.shell);
for (it = groupList.begin(); it != groupList.end(); ++it) {
LDAPGroupInfo group = *it;
TQCheckListItem* item = new TQCheckListItem(m_base->secondary_group_list, group.name, TQCheckListItem::CheckBox);
item->setOn(group.userlist.contains(m_user.distinguishedName));
}
// m_base->passwordEntry;
m_base->lastChanged->setText(m_user.password_last_changed.toString(TQt::TextDate));
if (m_user.password_expires) {
m_base->passwordExpireEnabled->setChecked(true);
m_base->passwordExpireDisabled->setChecked(false);
}
else {
m_base->passwordExpireEnabled->setChecked(false);
m_base->passwordExpireDisabled->setChecked(true);
}
m_base->expirationDate->setDateTime(m_user.password_expiration);
m_base->requirePasswordAging->setChecked(m_user.password_ages);
m_base->requirePasswordInterval->setValue(m_user.new_password_interval/24);
m_base->warnPasswordExpireInterval->setValue(m_user.new_password_warn_interval/24);
m_base->disablePasswordDelay->setValue(m_user.new_password_lockout_delay/24);
m_base->requirePasswordMinAge->setChecked(m_user.password_has_minimum_age);
m_base->passwordMinAge->setValue(m_user.password_minimum_age/24);
processLockouts();
}
void UserConfigDialog::slotOk() {
// Update data
// RAJA FIXME
// Special handler for new group
if (m_user.distinguishedName == "") {
m_user.name = m_base->loginName->text();
}
accept();
}
void UserConfigDialog::processLockouts() {
if (m_base->passwordExpireEnabled->isChecked()) {
m_base->expirationDate->setEnabled(true);
}
else {
m_base->expirationDate->setEnabled(false);
}
if (m_base->requirePasswordAging->isChecked()) {
m_base->requirePasswordInterval->setEnabled(true);
m_base->warnPasswordExpireInterval->setEnabled(true);
m_base->disablePasswordDelay->setEnabled(true);
}
else {
m_base->requirePasswordInterval->setEnabled(false);
m_base->warnPasswordExpireInterval->setEnabled(false);
m_base->disablePasswordDelay->setEnabled(false);
}
if (m_base->requirePasswordMinAge->isChecked()) {
m_base->passwordMinAge->setEnabled(true);
}
else {
m_base->passwordMinAge->setEnabled(false);
}
// Disable the primary group checkbox in the group list
TQListViewItemIterator it(m_base->secondary_group_list);
while (it.current()) {
if (it.current()->text(0) == m_base->primaryGroup->currentText()) {
dynamic_cast<TQCheckListItem*>(it.current())->setOn(true);
it.current()->setEnabled(false);
}
else {
it.current()->setEnabled(true);
if (it.current()->text(0) == m_prevPrimaryGroup) {
dynamic_cast<TQCheckListItem*>(it.current())->setOn(false);
}
}
++it;
}
// Special handler for new group
if ((m_user.distinguishedName == "") && (m_base->loginName->text() == "")) {
enableButton(KDialogBase::Ok, false);
}
else {
enableButton(KDialogBase::Ok, true);
}
m_prevPrimaryGroup = m_base->primaryGroup->currentText();
}
LDAPUserInfo UserConfigDialog::userProperties() {
return m_user;
}
#include "userconfigdlg.moc"
|