-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
questionFurther information is requestedFurther information is requested
Description
The command Set-ADDOUStructure is simply reading the tables stored in SQLite and then does all the queries and mappings using PowerShell Where-Object and hash tables. This makes the code difficult to read and debug.
The SQLite DB does use a proper schema and every data query should be done using T-SQL. This also helps to avoid and duplicates and following constraints defined in the DB schema.
The SQLite DB should provide views which would further help to understand what the tool does.
Three examples (though I'm not certain if they are build according intended design):
PropertyGroupMapping
CREATE VIEW PropertyGroupMapping
AS
SELECT
PG.rowid as PGID,
PG.OBJ_name as GroupName,
PG.OBJ_Scope as Scope,
PGM.OBJ_propertyname as PropertyName,
OB.OBJ_adclass as Class,
OB.OBJ_category as Category,
OB.OBJ_relatedfocus as Focus,
OB.OBJ_TypeOU as OUType,
OB.OBJ_TierAssoc as Tier,
ADA.OBJ_Guid as AttributeGuid,
ADA.OBJ_AdType as Type,
ADC.OBJ_name as ClassName,
ADC.OBJ_guid as ClassGuid
FROM
AP_PropGroups PG
LEFT JOIN
AP_PropertyGroupMap PGM
ON
PG.OBJ_name = PGM.OBJ_pgrpname
LEFT JOIN
AP_Objects OB
ON
PG.OBJ_refid = OB.OBJ_id
LEFT JOIN
AD_Attributes ADA
ON
PGM.OBJ_propertyname = ADA.OBJ_Name
LEFT JOIN
AD_Classes ADC
ON
OB.OBJ_adclass = ADC.OBJ_name
WHERE PG.OBJ_enabled AND OB.OBJ_enabled
PropertyGroupMappingWithIDs
CREATE VIEW PropertyGroupMappingWithIDs
AS
SELECT
PG.rowid as PGID,
PG.OBJ_name as GroupName,
PG.OBJ_Scope as Scope,
APR.OBJ_description as ADRightsDesc,
APR.OBJ_value as ADRights,
PGM.OBJ_propertyname as PropertyName,
PG.OBJ_refid as PropertyGroupOBJ_refid,
OBDest.OBJ_adclass as DestinationNameCHECK,
PG.OBJ_destination as PropertyGroupOBJ_destination,
OB.OBJ_adclass as Class,
OB.OBJ_category as Category,
OB.OBJ_relatedfocus as Focus,
OB.OBJ_TypeOU as OUType,
OB.OBJ_TierAssoc as Tier,
ADA.OBJ_Guid as AttributeGuid,
ADA.OBJ_AdType as Type,
ADC.OBJ_name as ClassName,
ADC.OBJ_guid as ClassGuid
FROM
AP_PropGroups PG
LEFT JOIN
AP_PropertyGroupMap PGM
ON
PG.OBJ_name = PGM.OBJ_pgrpname
LEFT JOIN
AP_Objects OB
ON
PG.OBJ_refid = OB.OBJ_id
LEFT JOIN
AP_Objects OBDest
ON
PG.OBJ_destination = OBDest.OBJ_id
LEFT JOIN
AD_Attributes ADA
ON
PGM.OBJ_propertyname = ADA.OBJ_Name
LEFT JOIN
AD_Classes ADC
ON
OB.OBJ_adclass = ADC.OBJ_name
LEFT JOIN
AP_Rights APR
ON PG.OBJ_rights = APR.OBJ_indicator
WHERE PG.OBJ_enabled AND OB.OBJ_enabled AND APR.OBJ_enabled
GetPropertyGroupFromADAttribute
CREATE VIEW GetPropertyGroupFromADAttribute
AS
SELECT
PG.OBJ_name as GroupName, PG.OBJ_Scope as Scope, PG.OBJ_enabled as Enabled,
PGM.OBJ_propertyname as PropertyName,
OB.OBJ_adclass as Class, OB.OBJ_category as Category, OB.OBJ_relatedfocus as Focus, OB.OBJ_TypeOU as OUType, OB.OBJ_TierAssoc as Tire,
ADA.OBJ_Name as AttributeName, ADA.OBJ_Guid as AttributeGuid, ADA.OBJ_AdType as Type
FROM
AD_Attributes ADA
LEFT JOIN
AP_PropertyGroupMap PGM
ON
ADA.OBJ_Name = PGM.OBJ_propertyname
LEFT JOIN
AP_Objects OB
ON
PGM.OBJ_relatedrefid = OB.OBJ_id
LEFT JOIN
AP_PropGroups PG
ON
PGM.OBJ_pgrpname = PG.OBJ_name
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested