mirror of
https://github.com/altlinux/admc.git
synced 2025-01-05 01:18:06 +03:00
FSMO code contents changed
Did some refactor, add fsmo role change signals and other functional for domain info item feature
This commit is contained in:
parent
4b62168462
commit
0b52e7558e
@ -126,8 +126,7 @@ void AllPoliciesFolderImpl::create_policy() {
|
||||
"group policy creation is prohibited by the setting. "
|
||||
"Connect to PDC-Emulator?"));
|
||||
if (answer == QMessageBox::Yes) {
|
||||
connect_host_with_role(ad, FSMORole_PDCEmulation);
|
||||
g_status->add_message(tr("PDC-Emulator is connected"), StatusType_Success);
|
||||
connect_to_PDC_emulator(ad, console);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
@ -373,8 +373,7 @@ void console_policy_edit(ConsoleWidget *console, const int item_type, const int
|
||||
"group policy editing is prohibited by the setting. "
|
||||
"Connect to PDC-Emulator?"));
|
||||
if (answer == QMessageBox::Yes) {
|
||||
connect_host_with_role(ad, FSMORole_PDCEmulation);
|
||||
g_status->add_message(QObject::tr("PDC-Emulator is connected"), StatusType_Success);
|
||||
connect_to_PDC_emulator(ad, console);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@ -592,8 +591,7 @@ void console_policy_delete(const QList<ConsoleWidget *> &console_list, PolicyRes
|
||||
"group policy deletion is prohibited by the setting. "
|
||||
"Connect to PDC-Emulator?"));
|
||||
if (answer == QMessageBox::Yes) {
|
||||
connect_host_with_role(ad, FSMORole_PDCEmulation);
|
||||
g_status->add_message(QObject::tr("PDC-Emulator is connected"), StatusType_Success);
|
||||
connect_to_PDC_emulator(ad, console_list[0]);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
@ -272,8 +272,7 @@ void PolicyOUImpl::create_and_link_gpo() {
|
||||
"group policy creation is prohibited by the setting. "
|
||||
"Connect to PDC-Emulator?"));
|
||||
if (answer == QMessageBox::Yes) {
|
||||
connect_host_with_role(ad, FSMORole_PDCEmulation);
|
||||
g_status->add_message(tr("PDC-Emulator is connected"), StatusType_Success);
|
||||
connect_to_PDC_emulator(ad, console);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
@ -61,6 +61,7 @@ FSMODialog::FSMODialog(AdInterface &ad, QWidget *parent)
|
||||
auto tab = new FSMOTab(title, role_dn);
|
||||
ui->tab_widget->add_tab(tab, title);
|
||||
tab->load(ad);
|
||||
connect(tab, &FSMOTab::master_changed, this, &FSMODialog::master_changed);
|
||||
}
|
||||
|
||||
ui->warning_widget->setVisible(false);
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
class AdInterface;
|
||||
|
||||
namespace Ui {
|
||||
@ -44,6 +45,9 @@ public:
|
||||
|
||||
private slots:
|
||||
void gpo_edit_PDC_check_toggled(bool is_checked);
|
||||
|
||||
signals:
|
||||
void master_changed(const QString &new_master_dn, const QString &string_fsmo_role);
|
||||
};
|
||||
|
||||
#endif /* FSMO_DIALOG_H */
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "utils.h"
|
||||
#include "fsmo/fsmo_utils.h"
|
||||
|
||||
|
||||
FSMOTab::FSMOTab(const QString &title, const QString &role_dn_arg) {
|
||||
ui = new Ui::FSMOTab();
|
||||
ui->setupUi(this);
|
||||
@ -67,12 +68,8 @@ void FSMOTab::change_master() {
|
||||
return;
|
||||
}
|
||||
|
||||
const QString new_master_service = [&]() {
|
||||
const AdObject rootDSE = ad.search_object("");
|
||||
const QString out = rootDSE.get_string(ATTRIBUTE_DS_SERVICE_NAME);
|
||||
|
||||
return out;
|
||||
}();
|
||||
const AdObject rootDSE = ad.search_object("");
|
||||
const QString new_master_service = rootDSE.get_string(ATTRIBUTE_DS_SERVICE_NAME);
|
||||
|
||||
const bool success = ad.attribute_replace_string(role_dn, ATTRIBUTE_FSMO_ROLE_OWNER, new_master_service);
|
||||
|
||||
@ -80,5 +77,7 @@ void FSMOTab::change_master() {
|
||||
|
||||
if (success) {
|
||||
load(ad);
|
||||
const QString new_master_dn = rootDSE.get_string(ATTRIBUTE_SERVER_NAME);
|
||||
emit master_changed(new_master_dn, fsmo_string_from_dn(role_dn));
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ private:
|
||||
QString role_dn;
|
||||
|
||||
void change_master();
|
||||
|
||||
signals:
|
||||
// TODO: Remove tabs and use signal from fsmo_dialog directly
|
||||
void master_changed(const QString &new_master_dn, const QString &string_fsmo_role);
|
||||
};
|
||||
|
||||
#endif /* FSMO_TAB_H */
|
||||
|
@ -5,8 +5,11 @@
|
||||
#include "adldap.h"
|
||||
#include "utils.h"
|
||||
#include "settings.h"
|
||||
#include "console_widget/console_widget.h"
|
||||
#include "status.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QModelIndex>
|
||||
|
||||
bool gpo_edit_without_PDC_disabled = true;
|
||||
|
||||
@ -49,9 +52,48 @@ bool current_dc_is_master_for_role(AdInterface &ad, FSMORole role)
|
||||
|
||||
void connect_host_with_role(AdInterface &ad, FSMORole role)
|
||||
{
|
||||
QString role_dn = dn_from_role(role);
|
||||
QString current_master = current_master_for_role_dn(ad, role_dn);
|
||||
QString current_master = current_master_for_role(ad, role);
|
||||
settings_set_variant(SETTING_host, current_master);
|
||||
AdInterface::set_dc(current_master);
|
||||
ad.update_dc();
|
||||
}
|
||||
|
||||
void connect_to_PDC_emulator(AdInterface &ad, ConsoleWidget *console)
|
||||
{
|
||||
connect_host_with_role(ad, FSMORole_PDCEmulation);
|
||||
console->refresh_scope(console->domain_info_index());
|
||||
g_status->add_message(QObject::tr("PDC-Emulator is connected"), StatusType_Success);
|
||||
}
|
||||
|
||||
QString current_master_for_role(AdInterface &ad, FSMORole role)
|
||||
{
|
||||
QString role_dn = dn_from_role(role);
|
||||
return current_master_for_role_dn(ad, role_dn);
|
||||
}
|
||||
|
||||
QString string_fsmo_role(FSMORole role)
|
||||
{
|
||||
switch (role) {
|
||||
case FSMORole_DomainDNS: return "Domain DNS";
|
||||
case FSMORole_ForestDNS: return "Forest DNS";
|
||||
case FSMORole_PDCEmulation: return "PDC Emulator";
|
||||
case FSMORole_Schema: return "Schema master";
|
||||
case FSMORole_DomainNaming: return "Domain naming master";
|
||||
case FSMORole_Infrastructure: return "Infrastructure master";
|
||||
case FSMORole_RidAllocation: return "RID master";
|
||||
|
||||
case FSMORole_COUNT: break;
|
||||
};
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString fsmo_string_from_dn(const QString &fsmo_role_dn)
|
||||
{
|
||||
for (int role = 0; role < FSMORole_COUNT; ++role) {
|
||||
if (dn_from_role(FSMORole(role)) == fsmo_role_dn) {
|
||||
return string_fsmo_role(FSMORole(role));
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
class QString;
|
||||
class AdInterface;
|
||||
class ConsoleWidget;
|
||||
|
||||
extern bool gpo_edit_without_PDC_disabled;
|
||||
|
||||
@ -18,10 +19,18 @@ enum FSMORole {
|
||||
FSMORole_COUNT,
|
||||
};
|
||||
|
||||
QString string_fsmo_role(FSMORole role);
|
||||
|
||||
QString fsmo_string_from_dn(const QString &fsmo_role_dn);
|
||||
|
||||
// Returns the DN of the object that
|
||||
// store's role's master in it's attributes
|
||||
QString dn_from_role(FSMORole role);
|
||||
|
||||
FSMORole fsmo_role_from_dn(const QString &role_dn);
|
||||
|
||||
QString current_master_for_role(AdInterface &ad, FSMORole role);
|
||||
|
||||
// Returns dns host name of role's master object (DC)
|
||||
QString current_master_for_role_dn(AdInterface &ad, QString role_dn);
|
||||
|
||||
@ -29,4 +38,6 @@ bool current_dc_is_master_for_role(AdInterface &ad, FSMORole role);
|
||||
|
||||
void connect_host_with_role(AdInterface &ad, FSMORole role);
|
||||
|
||||
void connect_to_PDC_emulator(AdInterface &ad, ConsoleWidget *console);
|
||||
|
||||
#endif // FSMO_UTILS_H
|
||||
|
Loading…
Reference in New Issue
Block a user