Add ability to set maximum terminal service users in group

master
Timothy Pearson 12 years ago
parent be64ff0e7e
commit aea462f777

@ -129,6 +129,23 @@ TQKeyedStringList GroupPermissionsDialog::selectedServers() {
return list; return list;
} }
void GroupPermissionsDialog::setSessionLimit(int limit, bool visible) {
if (visible) {
m_base->m_sessionLimitLabel->show();
m_base->m_sessionLimit->show();
}
else {
m_base->m_sessionLimitLabel->hide();
m_base->m_sessionLimit->hide();
}
m_base->m_sessionLimit->setValue(limit);
}
int GroupPermissionsDialog::sessionLimit() {
return m_base->m_sessionLimit->value();
}
void GroupPermissionsDialog::slotOk() { void GroupPermissionsDialog::slotOk() {
accept(); accept();
} }

@ -59,6 +59,8 @@ class GroupPermissionsDialog : public KDialogBase
void setAvailableServers(TQKeyedStringList list); void setAvailableServers(TQKeyedStringList list);
void setSelectedServers(TQKeyedStringList list); void setSelectedServers(TQKeyedStringList list);
TQKeyedStringList selectedServers(); TQKeyedStringList selectedServers();
void setSessionLimit(int limit, bool visible);
int sessionLimit();
public slots: public slots:
void slotOk(); void slotOk();

@ -41,7 +41,29 @@
<string></string> <string></string>
</property> </property>
</widget> </widget>
<widget class="TQGroupBox" row="1" column="0" colspan="2"> <widget class="TQLabel" row="1" column="0" colspan="0">
<property name="name">
<cstring>m_sessionLimitLabel</cstring>
</property>
<property name="text">
<string>Maximum Simultaneous Users:</string>
</property>
</widget>
<widget class="KIntNumInput" row="1" column="1" colspan="0">
<property name="name">
<cstring>m_sessionLimit</cstring>
</property>
<property name="minValue">
<int>0</int>
</property>
<property name="maxValue">
<int>65535</int>
</property>
<property name="value">
<int>0</int>
</property>
</widget>
<widget class="TQGroupBox" row="2" column="0" colspan="2">
<property name="name"> <property name="name">
<cstring>groupPermissionsSelector</cstring> <cstring>groupPermissionsSelector</cstring>
</property> </property>

@ -57,6 +57,17 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
</column> </column>
<column>
<property name="text">
<string>Maximum Simultaneous Users</string>
</property>
<property name="clickable">
<bool>true</bool>
</property>
<property name="resizeable">
<bool>true</bool>
</property>
</column>
<property name="name"> <property name="name">
<cstring>ts_list</cstring> <cstring>ts_list</cstring>
</property> </property>

@ -240,6 +240,7 @@ void UserManagementPart::terminalServiceAddGroupButtonClicked() {
keyedServerList.append(TQKeyedStringPair(TQString("%1").arg(*it2), 0)); keyedServerList.append(TQKeyedStringPair(TQString("%1").arg(*it2), 0));
} }
groupauthdlg.setAvailableServers(keyedServerList); groupauthdlg.setAvailableServers(keyedServerList);
groupauthdlg.setSessionLimit(0, true);
} }
if (groupauthdlg.exec() == TQDialog::Accepted) { if (groupauthdlg.exec() == TQDialog::Accepted) {
m_updateTerminalServiceAuthGroupList.clear(); m_updateTerminalServiceAuthGroupList.clear();
@ -251,6 +252,7 @@ void UserManagementPart::terminalServiceAddGroupButtonClicked() {
for (TQKeyedStringList::Iterator it = selectedServers.begin(); it != selectedServers.end(); ++it) { for (TQKeyedStringList::Iterator it = selectedServers.begin(); it != selectedServers.end(); ++it) {
agt.allowedServerNames.append((*it).first); agt.allowedServerNames.append((*it).first);
} }
agt.maximumActiveSessionCount = groupauthdlg.sessionLimit();
m_updateTerminalServiceAuthGroupList.append(agt); m_updateTerminalServiceAuthGroupList.append(agt);
m_commHandlerNextState = ModeUpdate_TerminalServices; m_commHandlerNextState = ModeUpdate_TerminalServices;
m_commHandlerNextMode = ModeUpdate; m_commHandlerNextMode = ModeUpdate;
@ -278,6 +280,7 @@ void UserManagementPart::terminalServiceModifyGroupButtonClicked() {
keyedServerList.append(TQKeyedStringPair(TQString("%1").arg(*it2), 0)); keyedServerList.append(TQKeyedStringPair(TQString("%1").arg(*it2), 0));
} }
groupauthdlg.setSelectedServers(keyedServerList); groupauthdlg.setSelectedServers(keyedServerList);
groupauthdlg.setSessionLimit((*it).maximumActiveSessionCount, true);
} }
groupauthdlg.setGroupName(item->text(0), false); groupauthdlg.setGroupName(item->text(0), false);
if (groupauthdlg.exec() == TQDialog::Accepted) { if (groupauthdlg.exec() == TQDialog::Accepted) {
@ -289,6 +292,7 @@ void UserManagementPart::terminalServiceModifyGroupButtonClicked() {
for (TQKeyedStringList::Iterator it = selectedServers.begin(); it != selectedServers.end(); ++it) { for (TQKeyedStringList::Iterator it = selectedServers.begin(); it != selectedServers.end(); ++it) {
agt.allowedServerNames.append((*it).first); agt.allowedServerNames.append((*it).first);
} }
agt.maximumActiveSessionCount = groupauthdlg.sessionLimit();
m_updateTerminalServiceAuthGroupList.append(agt); m_updateTerminalServiceAuthGroupList.append(agt);
m_commHandlerNextState = ModeUpdate_TerminalServices; m_commHandlerNextState = ModeUpdate_TerminalServices;
m_commHandlerNextMode = ModeUpdate; m_commHandlerNextMode = ModeUpdate;
@ -315,6 +319,7 @@ void UserManagementPart::terminalServiceDeleteGroupButtonClicked() {
void UserManagementPart::workspaceAddGroupButtonClicked() { void UserManagementPart::workspaceAddGroupButtonClicked() {
GroupPermissionsDialog groupauthdlg(0); GroupPermissionsDialog groupauthdlg(0);
groupauthdlg.setPermissionsSelectorLabel(i18n("Allowed Stations")); groupauthdlg.setPermissionsSelectorLabel(i18n("Allowed Stations"));
groupauthdlg.setSessionLimit(-1, false);
{ {
TQKeyedStringList friendlyStations; TQKeyedStringList friendlyStations;
for (StationList::iterator it = m_availableWorkspaceStationsList.begin(); it != m_availableWorkspaceStationsList.end(); ++it) { for (StationList::iterator it = m_availableWorkspaceStationsList.begin(); it != m_availableWorkspaceStationsList.end(); ++it) {
@ -344,6 +349,7 @@ void UserManagementPart::workspaceModifyGroupButtonClicked() {
GroupPermissionsDialog groupauthdlg(0); GroupPermissionsDialog groupauthdlg(0);
groupauthdlg.setPermissionsSelectorLabel(i18n("Allowed Stations")); groupauthdlg.setPermissionsSelectorLabel(i18n("Allowed Stations"));
groupauthdlg.setSessionLimit(-1, false);
{ {
TQKeyedStringList friendlyStations; TQKeyedStringList friendlyStations;
for (StationList::iterator it = m_availableWorkspaceStationsList.begin(); it != m_availableWorkspaceStationsList.end(); ++it) { for (StationList::iterator it = m_availableWorkspaceStationsList.begin(); it != m_availableWorkspaceStationsList.end(); ++it) {
@ -633,6 +639,7 @@ void UserManagementPart::mainEventLoop() {
} }
item->setText(0, TQString("%1").arg(info.groupName)); item->setText(0, TQString("%1").arg(info.groupName));
item->setText(1, info.allowedServerNames.join(", ")); item->setText(1, info.allowedServerNames.join(", "));
item->setText(2, TQString("%1").arg(info.maximumActiveSessionCount));
} }
it2 = TQListViewItemIterator(m_base->ts_list); it2 = TQListViewItemIterator(m_base->ts_list);
while (it2.current()) { while (it2.current()) {

@ -633,6 +633,7 @@ TQDataStream &operator<<( TQDataStream &s, const TerminalServiceAuthGroupType &a
s << agt.protocolVersion; s << agt.protocolVersion;
s << agt.groupName; s << agt.groupName;
s << agt.allowedServerNames; s << agt.allowedServerNames;
s << agt.maximumActiveSessionCount;
return s; return s;
} }
@ -649,6 +650,7 @@ TQDataStream &operator>>( TQDataStream &s, TerminalServiceAuthGroupType &agt )
s >> agt.protocolVersion; s >> agt.protocolVersion;
s >> agt.groupName; s >> agt.groupName;
s >> agt.allowedServerNames; s >> agt.allowedServerNames;
s >> agt.maximumActiveSessionCount;
return s; return s;
} }

@ -253,6 +253,7 @@ class TerminalServiceAuthGroupType
TQ_UINT32 protocolVersion; TQ_UINT32 protocolVersion;
TQString groupName; TQString groupName;
TQStringList allowedServerNames; TQStringList allowedServerNames;
TQ_UINT32 maximumActiveSessionCount;
}; };
#ifndef QT_NO_DATASTREAM #ifndef QT_NO_DATASTREAM

@ -263,12 +263,32 @@ void SysCtlSocket::commandLoop() {
else { else {
agt.protocolVersion = 1; agt.protocolVersion = 1;
agt.groupName = databasePermissionsCursor.value("groupname").toString(); agt.groupName = databasePermissionsCursor.value("groupname").toString();
agt.maximumActiveSessionCount = 0;
} }
agt.allowedServerNames.append(databasePermissionsCursor.value("server").toString()); agt.allowedServerNames.append(databasePermissionsCursor.value("server").toString());
list.append(agt); list.append(agt);
} }
// ...then search the session limit database for groups...
TQSqlCursor databaseLimitsCursor("groups", TRUE, m_terminals_database);
databaseLimitsCursor.select();
while (databaseLimitsCursor.next()) {
TerminalServiceAuthGroupType agt;
TerminalServiceAuthGroupList::iterator it = list.findByName(databaseLimitsCursor.value("groupname").toString());
if (it != list.end()) {
agt = *it;
list.remove(it);
}
else {
agt.protocolVersion = 1;
agt.groupName = databaseLimitsCursor.value("groupname").toString();
}
agt.maximumActiveSessionCount = databaseLimitsCursor.value("sesslimit").toUInt();
list.append(agt);
}
// ...then search LDAP for groups that were not already in the database // ...then search LDAP for groups that were not already in the database
struct group* group; struct group* group;
setgrent(); setgrent();
@ -279,6 +299,7 @@ void SysCtlSocket::commandLoop() {
if (it == list.end()) { if (it == list.end()) {
agt.protocolVersion = 1; agt.protocolVersion = 1;
agt.groupName = TQString(group->gr_name); agt.groupName = TQString(group->gr_name);
agt.maximumActiveSessionCount = 0;
list.append(agt); list.append(agt);
} }
} }
@ -348,6 +369,7 @@ void SysCtlSocket::commandLoop() {
bool success = true; bool success = true;
TQSqlCursor databasePermissionsCursor("allowed_servers", TRUE, m_terminals_database); TQSqlCursor databasePermissionsCursor("allowed_servers", TRUE, m_terminals_database);
TQSqlCursor databaseLimitsCursor("groups", TRUE, m_terminals_database);
TerminalServiceAuthGroupList::iterator it; TerminalServiceAuthGroupList::iterator it;
for (it = list.begin(); it != list.end(); ++it) { for (it = list.begin(); it != list.end(); ++it) {
TerminalServiceAuthGroupType agt = *it; TerminalServiceAuthGroupType agt = *it;
@ -358,6 +380,11 @@ void SysCtlSocket::commandLoop() {
databasePermissionsCursor.primeDelete(); databasePermissionsCursor.primeDelete();
databasePermissionsCursor.del(false); databasePermissionsCursor.del(false);
} }
databaseLimitsCursor.select(TQString("groupname='%1'").arg(agt.groupName));
while (databaseLimitsCursor.next()) {
databaseLimitsCursor.primeDelete();
databaseLimitsCursor.del(false);
}
// Insert all entries for this group from the information structure // Insert all entries for this group from the information structure
TQStringList::iterator it2; TQStringList::iterator it2;
@ -366,6 +393,10 @@ void SysCtlSocket::commandLoop() {
buffer->setValue("groupname", agt.groupName); buffer->setValue("groupname", agt.groupName);
buffer->setValue("server", *it2); buffer->setValue("server", *it2);
databasePermissionsCursor.insert(); databasePermissionsCursor.insert();
buffer = databaseLimitsCursor.primeInsert();
buffer->setValue("groupname", agt.groupName);
buffer->setValue("sesslimit", agt.maximumActiveSessionCount);
databaseLimitsCursor.insert();
} }
} }

Loading…
Cancel
Save