-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't working
Description
The guids for extended rights stored in are wrong.
You may update using the following process:
# Correct Extended Rights GUIDs
# Update AD_Attributes to support overlapping GUIDs between AD attributes and rights attribute
# The current table gets renamed, a new table with updated setting is created, data copied and old one removed.
Invoke-SqliteQuery -Connection $conn -Query @"
PRAGMA foreign_keys=off;
BEGIN TRANSACTION;
ALTER TABLE AD_Attributes RENAME TO oldAD_Attributes;
CREATE TABLE "AD_Attributes" (
"OBJ_Name" VARCHAR NOT NULL UNIQUE,
"OBJ_guid" VARCHAR NOT NULL,
"OBJ_adtype" VARCHAR NOT NULL,
PRIMARY KEY("OBJ_adtype","OBJ_Name"),
UNIQUE("OBJ_adtype","OBJ_guid")
);
INSERT INTO AD_Attributes
SELECT * FROM oldAD_Attributes;
DROP TABLE oldAD_Attributes;
COMMIT;
PRAGMA foreign_keys=on;
"@
# Cleanup database after deleting a table
Invoke-SqliteQuery -Connection $conn -Query "VACUUM"
# Gather data in Forest with Exchange schema
$RootDSE = Get-ADRootDSE
Get-ADObject -SearchBase $RootDSE.configurationNamingContext -SearchScope Subtree -Filter { ObjectClass -eq 'ControlAccessRight' } `
-Properties rightsGuid -PipelineVariable ADObj |
Export-Csv C:\Temp\ExtendedRightsGuidMapping.csv -NoTypeInformation
# Load discovered Data and check how many need to be updated
(Import-Csv C:\Temp\ExtendedRightsGuidMapping.csv -PipelineVariable ADObj |
%{ Invoke-SqliteQuery -Connection $conn -Query "Select OBJ_Name,OBJ_guid FROM AD_Attributes WHERE OBJ_Name = '$($_.Name)' and OBJ_guid <> '$($_.rightsGUID)' and OBJ_adtype = 'controlAccessRight'" | Select *, @{n="ADGuid";e={ $ADObj.rightsGuid }} } ).count
( Invoke-SqliteQuery -Connection $conn -Query "Select * FROM AD_Attributes where OBJ_adtype = 'controlAccessRight'" ).count
# update GUIDs
# Note: one error is expected The following share the same GUID
# 'DNS-Host-Name-Attributes' - '72e39547-7b18-11d1-adef-00c04fd8d5cd'
# 'Validated-DNS-Host-Name' - '72e39547-7b18-11d1-adef-00c04fd8d5cd'
Import-Csv C:\Temp\ExtendedRightsGuidMapping.csv -PipelineVariable ADObj |
%{ Write-Host "Updating '$($_.name)' - '$($_.rightsGUID)'"; Invoke-SqliteQuery -Connection $conn -Query "UPDATE AD_Attributes SET OBJ_guid = '$($_.rightsGUID)' WHERE OBJ_Name = '$($_.Name)' and OBJ_guid <> '$($_.rightsGUID)' and OBJ_adtype = 'controlAccessRight'" }
# Load discovered Data and check again how many need to be updated. This time nothing should return
(Import-Csv C:\Temp\ExtendedRightsGuidMapping.csv -PipelineVariable ADObj |
%{ Invoke-SqliteQuery -Connection $conn -Query "Select OBJ_Name,OBJ_guid FROM AD_Attributes WHERE OBJ_Name = '$($_.Name)' and OBJ_guid <> '$($_.rightsGUID)' and OBJ_adtype = 'controlAccessRight'" | Select *, @{n="ADGuid";e={ $ADObj.rightsGuid }} } ).count
# Set schema version to 'current' date (yyyymmdd) this version is now for 2022-07-19
Invoke-SqliteQuery -Connection $conn -Query "PRAGMA user_version = 20220719"
# verify schema version
Invoke-SqliteQuery -Connection $conn -Query "PRAGMA user_version"
$conn.close()
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working