From 06ae16c20172cf7c114182072524538bfdaa5ab0 Mon Sep 17 00:00:00 2001 From: DimDone Date: Tue, 16 Jul 2024 23:20:32 +0400 Subject: [PATCH 1/3] Fixed the displaying of optional attributes Fixed the displaying of optional attributes msDS-User-Account-Control-Computed and msDS-User-Password-Expyre-Time-Computed --- src/adldap/ad_config.cpp | 2 +- src/adldap/ad_defines.h | 2 ++ src/adldap/ad_display.cpp | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/adldap/ad_config.cpp b/src/adldap/ad_config.cpp index 73009d77..69111de4 100644 --- a/src/adldap/ad_config.cpp +++ b/src/adldap/ad_config.cpp @@ -558,7 +558,6 @@ AttributeType AdConfig::get_attribute_type(const QString &attribute) const { const QString attribute_syntax = schema.get_string(ATTRIBUTE_ATTRIBUTE_SYNTAX); const QString om_syntax = schema.get_string(ATTRIBUTE_OM_SYNTAX); - if (type_map.contains(attribute_syntax) && type_map[attribute_syntax].contains(om_syntax)) { return type_map[attribute_syntax][om_syntax]; } else { @@ -576,6 +575,7 @@ LargeIntegerSubtype AdConfig::get_attribute_large_integer_subtype(const QString ATTRIBUTE_LOCKOUT_TIME, ATTRIBUTE_BAD_PWD_TIME, ATTRIBUTE_CREATION_TIME, + ATTRIBUTE_MSDS_USER_PASSWORD_EXPIRY_TIME_COMPUTED, }; static const QList timespans = { ATTRIBUTE_MAX_PWD_AGE, diff --git a/src/adldap/ad_defines.h b/src/adldap/ad_defines.h index 7c23b80a..d50371be 100644 --- a/src/adldap/ad_defines.h +++ b/src/adldap/ad_defines.h @@ -205,6 +205,8 @@ enum SystemFlagsBit { #define ATTRIBUTE_OBJECT_VERSION "objectVersion" #define ATTRIBUTE_SERVER_REFERENCE "serverReference" #define ATTRIBUTE_SERVER_REFERENCE_BL "serverReferenceBL" +#define ATTRIBUTE_MSDS_USER_PASSWORD_EXPIRY_TIME_COMPUTED "msDS-UserPasswordExpiryTimeComputed" +#define ATTRIBUTE_MSDS_USER_ACCOUNT_CONTROL_COMPUTED "msDS-User-Account-Control-Computed" #define CLASS_GROUP "group" diff --git a/src/adldap/ad_display.cpp b/src/adldap/ad_display.cpp index 138ee3c8..ce22cec1 100644 --- a/src/adldap/ad_display.cpp +++ b/src/adldap/ad_display.cpp @@ -31,6 +31,7 @@ #include #include #include +#include const qint64 SECONDS_TO_MILLIS = 1000LL; const qint64 MINUTES_TO_SECONDS = 60LL; @@ -63,7 +64,7 @@ QString attribute_display_value(const QString &attribute, const QByteArray &valu return samaccounttype_to_display_value(value); } else if (attribute == ATTRIBUTE_PRIMARY_GROUP_ID) { return primarygrouptype_to_display_value(value); - } else if (attribute == ATTRIBUTE_GROUP_TYPE || attribute == ATTRIBUTE_SYSTEM_FLAGS) { + } else if (attribute == ATTRIBUTE_GROUP_TYPE || attribute == ATTRIBUTE_SYSTEM_FLAGS || attribute == ATTRIBUTE_MSDS_USER_ACCOUNT_CONTROL_COMPUTED) { return attribute_hex_displayed_value(attribute, value); } else if (attribute == ATTRIBUTE_MS_DS_SUPPORTED_ETYPES) { return msds_supported_etypes_to_display_value(value); @@ -73,7 +74,6 @@ QString attribute_display_value(const QString &attribute, const QByteArray &valu } case AttributeType_LargeInteger: { const LargeIntegerSubtype subtype = adconfig->get_attribute_large_integer_subtype(attribute); - switch (subtype) { case LargeIntegerSubtype_Datetime: return large_integer_datetime_display_value(attribute, value, adconfig); case LargeIntegerSubtype_Timespan: return timespan_display_value(value); From 7cc8ffd75d71ff537f38b7a6d53b1776186922c0 Mon Sep 17 00:00:00 2001 From: DimDone Date: Thu, 25 Jul 2024 02:32:51 +0400 Subject: [PATCH 2/3] Fixed the displaying optional attributes after reset action Now optional attributes stay visible after reset action --- src/adldap/ad_display.cpp | 1 - src/admc/tabs/attributes_tab.cpp | 9 ++++----- src/admc/tabs/attributes_tab.h | 1 + 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/adldap/ad_display.cpp b/src/adldap/ad_display.cpp index ce22cec1..18e04538 100644 --- a/src/adldap/ad_display.cpp +++ b/src/adldap/ad_display.cpp @@ -31,7 +31,6 @@ #include #include #include -#include const qint64 SECONDS_TO_MILLIS = 1000LL; const qint64 MINUTES_TO_SECONDS = 60LL; diff --git a/src/admc/tabs/attributes_tab.cpp b/src/admc/tabs/attributes_tab.cpp index 4748d802..fbd59210 100644 --- a/src/admc/tabs/attributes_tab.cpp +++ b/src/admc/tabs/attributes_tab.cpp @@ -90,8 +90,8 @@ AttributesTabEdit::AttributesTabEdit(QTreeView *view_arg, QPushButton *filter_bu QItemSelectionModel *selection_model = view->selectionModel(); - bool load_optional_is_set = settings_get_variant(SETTING_load_optional_attribute_values).toBool(); - load_optional_attrs_button->setVisible(!load_optional_is_set); + optional_attrs_values_is_loaded = settings_get_variant(SETTING_load_optional_attribute_values).toBool(); + load_optional_attrs_button->setVisible(!optional_attrs_values_is_loaded); connect( selection_model, &QItemSelectionModel::selectionChanged, @@ -235,7 +235,7 @@ void AttributesTabEdit::load_optional_attribute_values(AdInterface &ad) { } } } - + optional_attrs_values_is_loaded = true; proxy->update_set_attributes(optional_set_attrs); } @@ -290,8 +290,7 @@ void AttributesTabEdit::load(AdInterface &ad, const AdObject &object) { proxy->load(object); - bool load_optional = settings_get_variant(SETTING_load_optional_attribute_values).toBool(); - if (load_optional) { + if (optional_attrs_values_is_loaded) { load_optional_attribute_values(ad); } else { diff --git a/src/admc/tabs/attributes_tab.h b/src/admc/tabs/attributes_tab.h index 74882bc5..2306a7d5 100644 --- a/src/admc/tabs/attributes_tab.h +++ b/src/admc/tabs/attributes_tab.h @@ -83,6 +83,7 @@ class AttributesTabEdit final : public AttributeEdit { QHash> current; QList not_specified_optional_attributes; QString object_dn; + bool optional_attrs_values_is_loaded; void update_edit_and_view_buttons(); void on_double_click(); From eff7cb26ed26eb1a127bdf4dcc963408c4629b96 Mon Sep 17 00:00:00 2001 From: DimDone Date: Fri, 26 Jul 2024 05:02:36 +0400 Subject: [PATCH 3/3] Added copy action to list of attributes --- src/admc/tabs/attributes_tab.cpp | 23 ++++++++++++++++++++++- src/admc/tabs/attributes_tab.h | 2 ++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/admc/tabs/attributes_tab.cpp b/src/admc/tabs/attributes_tab.cpp index fbd59210..2b0e9250 100644 --- a/src/admc/tabs/attributes_tab.cpp +++ b/src/admc/tabs/attributes_tab.cpp @@ -34,6 +34,8 @@ #include #include #include +#include +#include QString attribute_type_display_string(const AttributeType type); @@ -98,6 +100,8 @@ AttributesTabEdit::AttributesTabEdit(QTreeView *view_arg, QPushButton *filter_bu this, &AttributesTabEdit::update_edit_and_view_buttons); update_edit_and_view_buttons(); + view->installEventFilter(this); + connect( view, &QAbstractItemView::doubleClicked, this, &AttributesTabEdit::on_double_click); @@ -147,7 +151,6 @@ QList AttributesTabEdit::get_selected_row() const { void AttributesTabEdit::update_edit_and_view_buttons() { const QList selected_row = get_selected_row(); - const bool no_selection = selected_row.isEmpty(); if (no_selection) { edit_button->setVisible(true); @@ -175,6 +178,24 @@ void AttributesTabEdit::update_edit_and_view_buttons() { } } +void AttributesTabEdit::copy_action(){ + const QList selected_row = get_selected_row(); + QApplication::clipboard()->setText(selected_row[AttributesColumn_Value]->text()); +} + +bool AttributesTabEdit::eventFilter(QObject *watched, QEvent *event){ + if (watched == view && event->type() == 82){ + QMenu menu; + QAction* saveAction = menu.addAction("Копировать"); + connect( + saveAction, &QAction::triggered, + this, &AttributesTabEdit::copy_action); + menu.exec(QCursor::pos()); + return true; + } + return QObject::eventFilter(watched, event); +} + void AttributesTabEdit::on_double_click() { const QList selected_row = get_selected_row(); const QString attribute = selected_row[AttributesColumn_Name]->text(); diff --git a/src/admc/tabs/attributes_tab.h b/src/admc/tabs/attributes_tab.h index 2306a7d5..57c4aea8 100644 --- a/src/admc/tabs/attributes_tab.h +++ b/src/admc/tabs/attributes_tab.h @@ -90,6 +90,8 @@ class AttributesTabEdit final : public AttributeEdit { void edit_attribute(); void view_attribute(); void on_load_optional(); + bool eventFilter(QObject *watched, QEvent *event); + void copy_action(); void load_optional_attribute_values(AdInterface &ad); void load_row(const QList &row, const QString &attribute, const QList &values); QList get_selected_row() const;