1
0
mirror of https://github.com/altlinux/admc.git synced 2025-01-05 01:18:06 +03:00

Attributes with hexadecimal displayed values are added

Attribute userAccountControl, msDs-Supported and systemFlags values
are displayed as hexadecimal
This commit is contained in:
Semyon Knyazev 2023-04-20 00:57:32 +04:00
parent 226a664edf
commit c69156bee1
5 changed files with 90 additions and 22 deletions

View File

@ -85,8 +85,8 @@ enum GroupType {
};
enum SystemFlagsBit {
SystemFlagsBit_CannotMove = 0x04000000,
SystemFlagsBit_CannotRename = 0x08000000,
SystemFlagsBit_DomainCannotMove = 0x04000000,
SystemFlagsBit_DomainCannotRename = 0x08000000,
SystemFlagsBit_CannotDelete = 0x80000000
};
@ -199,6 +199,7 @@ enum SystemFlagsBit {
#define ATTRIBUTE_CREATION_TIME "creationTime"
#define ATTRIBUTE_LOCKOUT_OBSERVATION_WINDOW "lockOutObservationWindow"
#define ATTRIBUTE_FORCE_LOGOFF "forceLogoff"
#define ATTRIBUTE_MS_DS_SUPPORTED_ETYPES "msDS-SupportedEncryptionTypes"
#define CLASS_GROUP "group"
#define CLASS_USER "user"
@ -306,6 +307,14 @@ const long long MILLIS_TO_100_NANOS = 10000LL;
#define SAM_NAME_MAX_LENGTH 20
#define SAM_NAME_COMPUTER_MAX_LENGTH 16
// NOTE: define supported encryption types bit flags
// for msDs-SupportedEncryptionTypes attribute
#define ETYPES_DES_CBC_CRC 0x00000001
#define ETYPES_DES_CBC_MD5 0x00000002
#define ETYPES_RC4_HMAC_MD5 0x00000004
#define ETYPES_AES128_CTS_HMAC_SHA1_96 0x00000008
#define ETYPES_AES256_CTS_HMAC_SHA1_96 0x00000010
enum SearchScope {
SearchScope_Object,
SearchScope_Children,

View File

@ -45,7 +45,8 @@ QString guid_to_display_value(const QByteArray &bytes);
QString uac_to_display_value(const QByteArray &bytes);
QString samaccounttype_to_display_value(const QByteArray &bytes);
QString primarygrouptype_to_display_value(const QByteArray &bytes);
QString grouptype_to_display_value(const QByteArray &bytes);
QString msds_supported_etypes_to_display_value(const QByteArray &bytes);
QString attribute_hex_displayed_value(const QString &attribute, const QByteArray &bytes);
QString attribute_display_value(const QString &attribute, const QByteArray &value, const AdConfig *adconfig) {
if (adconfig == nullptr) {
@ -62,8 +63,10 @@ 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) {
return grouptype_to_display_value(value);
} else if (attribute == ATTRIBUTE_GROUP_TYPE || attribute == ATTRIBUTE_SYSTEM_FLAGS) {
return attribute_hex_displayed_value(attribute, value);
} else if (attribute == ATTRIBUTE_MS_DS_SUPPORTED_ETYPES) {
return msds_supported_etypes_to_display_value(value);
} else {
return QString(value);
}
@ -358,7 +361,7 @@ QString uac_to_display_value(const QByteArray &bytes) {
return out_string;
}();
const QString out = QString("%1 = ( %2 )").arg(QString(bytes), masks_string);
const QString out = QString("0x%1 = ( %2 )").arg(QString::number((quint32)uac, 16), masks_string);
return out;
}
@ -427,7 +430,13 @@ QString primarygrouptype_to_display_value(const QByteArray &bytes) {
}
}
QString grouptype_to_display_value(const QByteArray &bytes) {
bool attribute_value_is_hex_displayed(const QString &attribute) {
//TODO: Add here attributes with hex displayed values
return (attribute == ATTRIBUTE_GROUP_TYPE || attribute == ATTRIBUTE_USER_ACCOUNT_CONTROL ||
attribute == ATTRIBUTE_MS_DS_SUPPORTED_ETYPES || attribute == ATTRIBUTE_SYSTEM_FLAGS);
}
QString msds_supported_etypes_to_display_value(const QByteArray &bytes) {
bool toInt_ok;
const int value_int = bytes.toInt(&toInt_ok);
@ -435,15 +444,45 @@ QString grouptype_to_display_value(const QByteArray &bytes) {
return QCoreApplication::translate("attribute_display", "<invalid value>");
}
const QHash<int, QString> mask_name_map = {
//TODO: change strings according to rsat
{GROUP_TYPE_BIT_SYSTEM, "SYSTEM_GROUP"},
{GROUP_TYPE_BIT_SECURITY, "SECURITY_ENABLED"},
{group_scope_bit(GroupScope_Global), "ACCOUNT_GROUP"},
{group_scope_bit(GroupScope_DomainLocal), "RESOURCE_GROUP"},
{group_scope_bit(GroupScope_Universal), "UNIVERSAL_GROUP"},
// NOTE: using separate list instead of map's
// keys() because keys() is unordered and we need
// order so that display string is consistent
const QList<int> mask_list = {
ETYPES_DES_CBC_CRC,
ETYPES_DES_CBC_MD5,
ETYPES_RC4_HMAC_MD5,
ETYPES_AES128_CTS_HMAC_SHA1_96,
ETYPES_AES256_CTS_HMAC_SHA1_96
};
const QHash<int, QString> mask_name_map = {
{ETYPES_DES_CBC_CRC, "DES_CBC_CRC"},
{ETYPES_DES_CBC_MD5, "DES_CBC_MD5"},
{ETYPES_RC4_HMAC_MD5, "RC4_HMAC_MD5"},
{ETYPES_AES128_CTS_HMAC_SHA1_96, "AES128_CTS_HMAC_SHA1_96"},
{ETYPES_AES256_CTS_HMAC_SHA1_96, "AES256_CTS_HMAC_SHA1_96"},
};
QStringList masks_strings;
for (const int mask : mask_list) {
if (bitmask_is_set(value_int, mask))
masks_strings.append(mask_name_map[mask]);
}
QString display_value = QString("0x%1 = ( %2 )").arg(QString::number((quint32)value_int, 16), masks_strings.join(" | "));
return display_value;
}
QString attribute_hex_displayed_value(const QString &attribute, const QByteArray &bytes) {
bool toInt_ok;
const int value_int = bytes.toInt(&toInt_ok);
if (!toInt_ok) {
return QCoreApplication::translate("attribute_display", "<invalid value>");
}
const QHash<int, QString> mask_name_map = attribute_value_bit_string_map(attribute);
QStringList masks_strings;
for (const int mask : mask_name_map.keys()) {
if (bitmask_is_set(value_int, mask))
@ -453,8 +492,3 @@ QString grouptype_to_display_value(const QByteArray &bytes) {
QString display_value = QString("0x%1 = ( %2 )").arg(QString::number((quint32)value_int, 16), masks_strings.join(" | "));
return display_value;
}
bool attribute_value_is_hex_displayed(const QString &attribute) {
//TODO: Add here attributes with hex displayed values
return (attribute == ATTRIBUTE_GROUP_TYPE /* || attribute == ... */);
}

View File

@ -465,3 +465,25 @@ QString escape_name_for_dn(const QString &unescaped) {
return out;
}
QHash<int, QString> attribute_value_bit_string_map(const QString &attribute)
{
QHash<int, QString> bit_string_map;
if (attribute == ATTRIBUTE_GROUP_TYPE) {
bit_string_map = {
{GROUP_TYPE_BIT_SYSTEM, "SYSTEM_GROUP"},
{GROUP_TYPE_BIT_SECURITY, "SECURITY_ENABLED"},
{group_scope_bit(GroupScope_Global), "ACCOUNT_GROUP"},
{group_scope_bit(GroupScope_DomainLocal), "RESOURCE_GROUP"},
{group_scope_bit(GroupScope_Universal), "UNIVERSAL_GROUP"},
};
}
else if (attribute == ATTRIBUTE_SYSTEM_FLAGS) {
bit_string_map = {
{SystemFlagsBit_DomainCannotMove, "DOMAIN_DISALLOW_MOVE"},
{SystemFlagsBit_DomainCannotRename, "DOMAIN_DISALLOW_RENAME"},
{SystemFlagsBit_CannotDelete, "DISALLOW_DELETE"}
};
}
return bit_string_map;
}

View File

@ -27,6 +27,7 @@
*/
#include "ad_defines.h"
#include <QHash>
class QString;
class QDateTime;
@ -85,4 +86,6 @@ QString attribute_type_display_string(const AttributeType type);
QString int_to_hex_string(const int n);
QHash<int, QString> attribute_value_bit_string_map(const QString &attribute);
#endif /* AD_UTILS_H */

View File

@ -1545,7 +1545,7 @@ void console_object_load(const QList<QStandardItem *> row, const AdObject &objec
console_object_item_data_load(row[0], object);
const bool cannot_move = object.get_system_flag(SystemFlagsBit_CannotMove);
const bool cannot_move = object.get_system_flag(SystemFlagsBit_DomainCannotMove);
for (auto item : row) {
item->setDragEnabled(!cannot_move);
@ -1561,10 +1561,10 @@ void console_object_item_data_load(QStandardItem *item, const AdObject &object)
const QList<QString> object_classes = object.get_strings(ATTRIBUTE_OBJECT_CLASS);
item->setData(QVariant(object_classes), ObjectRole_ObjectClasses);
const bool cannot_move = object.get_system_flag(SystemFlagsBit_CannotMove);
const bool cannot_move = object.get_system_flag(SystemFlagsBit_DomainCannotMove);
item->setData(cannot_move, ObjectRole_CannotMove);
const bool cannot_rename = object.get_system_flag(SystemFlagsBit_CannotRename);
const bool cannot_rename = object.get_system_flag(SystemFlagsBit_DomainCannotRename);
item->setData(cannot_rename, ObjectRole_CannotRename);
const bool cannot_delete = object.get_system_flag(SystemFlagsBit_CannotDelete);