Skip to content

Commit

Permalink
finalised code changes for the capability to create differential sync…
Browse files Browse the repository at this point in the history
… rule scripts.
  • Loading branch information
NileshGhodekar committed Nov 23, 2016
1 parent faa6c49 commit a95986c
Show file tree
Hide file tree
Showing 14 changed files with 675 additions and 609 deletions.
8 changes: 8 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ All notable changes to AADConnectConfigDocumenter project will be documented in

------------

### Version 1.16.1123.0

#### Added

* Implemented capability to generate PowerShell scripts for deploying synchronisation rule changes.

------------

### Version 1.16.0919.0

#### Fixed
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ The goal of this project is to:

* To enable quick understanding of the synchronization configuration and "how it happens"!
* To build confidence in getting things right when making changes to the default configuration!!
* To know what was changed when you applied a new build / configuration of Azure AD Connect or added/udpated custom sync rules!!!
* To know what was changed when you applied a new build / configuration of Azure AD Connect or added/updated custom sync rules!!!
* **NEW!** To generate the PowerShell script to migrate the sync rule differences or customisations from your "Pilot" server to "Production" server!!!!

Prerequisites:

1. .NET Framework 4.5 to be able to run the tool
2. A fair understanding of MIIS 2003 / ILM 2007 / FIM 2010 / MIM 2016 sync engine technical concepts to be able to understand the report. A sample report generated by the tool can be found listed in the [Wiki](https://github.com/Microsoft/AADConnectConfigDocumenter/wiki/Sample-Report) section.
1. .NET Framework 4.5 to be able to run the tool.
2. A modern browser (e.g. Microsoft Edge) to view the report.
3. A fair understanding of MIIS 2003 / ILM 2007 / FIM 2010 / MIM 2016 / AAD Sync sync engine technical concepts to be able to understand the report. A sample report generated by the tool can be found listed in the [Wiki](https://github.com/Microsoft/AADConnectConfigDocumenter/wiki/Sample-Report) section.

How to use the tool:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
<DependentUpon>DocumenterResources.resx</DependentUpon>
</Compile>
<Compile Include="Extensible2ConnectorDocumenter.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Logger.cs" />
<Compile Include="LoggerCallContextItems.cs" />
<Compile Include="MetaverseDocumenter.cs" />
Expand All @@ -90,6 +89,14 @@
<None Include="..\Settings.StyleCop">
<Link>Settings.StyleCop</Link>
</None>
<EmbeddedResource Include="Scripts\PowerShellScriptHeader.ps1" />
<EmbeddedResource Include="Scripts\PowerShellScriptSectionHeader.ps1" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Scripts\Documenter.js" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Scripts\Documenter.css" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
Expand Down
68 changes: 37 additions & 31 deletions src/AzureADConnectSyncDocumenter/Documenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace AzureADConnectConfigDocumenter
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web.UI;
using System.Xml;
using System.Xml.Linq;
Expand Down Expand Up @@ -228,6 +229,7 @@ protected static XNamespace MmsDsmlNamespace

/// <summary>
/// Gets or sets a value indicating whether the config element is present in production only.
/// If the values is <c>true</c>, indicates the sync rule is present in production only. If the values is <c>false</c>, does NOT indicate the sync rule is present in pilot only.
/// </summary>
protected bool ProductionOnly { get; set; }

Expand Down Expand Up @@ -487,7 +489,7 @@ protected static DataSet GetDiffgram(DataSet pilotDataSet, DataSet productionDat
diffGramDataSet.ExtendedProperties.Add(Documenter.CanHide, true);

// Loop all ignore last table which is PrintSetting table
for (var i = 0; i < diffGramDataSet.Tables.Count - 1; ++i)
for (var i = 0; i < diffGramDataSet.Tables.Count - 1; ++i)
{
diffGramDataSet.Tables[i].Columns.Add(Documenter.HtmlTableRowVisibilityStatusColumn);

Expand Down Expand Up @@ -905,7 +907,7 @@ protected static void WriteReportHeader(HtmlTextWriter htmlWriter)
htmlWriter.WriteBeginTag("style");
htmlWriter.WriteAttribute("type", "text/css");
htmlWriter.Write(HtmlTextWriter.TagRightChar);
htmlWriter.Write(DocumenterResources.StyleSheet);
htmlWriter.Write(GetEmbeddedScriptResource("Documenter.css"));
htmlWriter.WriteEndTag("style");
htmlWriter.WriteLine();

Expand All @@ -914,34 +916,8 @@ protected static void WriteReportHeader(HtmlTextWriter htmlWriter)
#region script

htmlWriter.WriteFullBeginTag("script");
htmlWriter.WriteLine("function ToggleVisibility() {");
htmlWriter.WriteLine("var x = document.getElementById(\"OnlyShowChanges\");");
htmlWriter.WriteLine("var elements = document.getElementsByClassName(\"" + Documenter.CanHide + "\");");
htmlWriter.WriteLine("for (var i = 0; i < elements.length; ++i) {");
htmlWriter.WriteLine("if (x.checked == true) {");
htmlWriter.WriteLine("elements[i].style.display = \"none\";");
htmlWriter.WriteLine("}");
htmlWriter.WriteLine("else {");
htmlWriter.WriteLine("elements[i].style.display = \"\";");
htmlWriter.WriteLine("}");
htmlWriter.WriteLine("}");
htmlWriter.WriteLine("var downloadLink = document.getElementById(\"DownloadLink\");");
htmlWriter.WriteLine("if (x.checked == true) {");
htmlWriter.WriteLine("var scripts = document.getElementsByClassName(\"PowerShellScript\");");
htmlWriter.WriteLine("var data = `" + DocumenterResources.PowerShellScriptHeader + Environment.NewLine + Environment.NewLine + "`;");
htmlWriter.WriteLine("for (var i = 0; i < scripts.length; ++i) {");
htmlWriter.WriteLine("data += scripts[i].innerText;");
htmlWriter.WriteLine("}");
htmlWriter.WriteLine("var file = new Blob([data.replace(/([^\\r])\\n/g, \"$1\\r\\n\")], {type: \"text/plain\"});");
htmlWriter.WriteLine("var href = URL.createObjectURL(file);");
htmlWriter.WriteLine("downloadLink.href = href;");
htmlWriter.WriteLine("downloadLink.style.display = \"\";");
htmlWriter.WriteLine("}");
htmlWriter.WriteLine("else {");
htmlWriter.WriteLine("downloadLink.style.display = \"none\";");
htmlWriter.WriteLine("}");
htmlWriter.WriteLine("}");
htmlWriter.WriteLine();
htmlWriter.WriteLine(GetEmbeddedScriptResource("Documenter.js"));
htmlWriter.WriteEndTag("script");
htmlWriter.WriteLine();

Expand All @@ -960,6 +936,29 @@ protected static void WriteReportHeader(HtmlTextWriter htmlWriter)
}
}

/// <summary>
/// Gets the embedded script resource
/// </summary>
/// <param name="resourceName">Name of the embedded script resource</param>
/// <returns>The script resource</returns>
protected static string GetEmbeddedScriptResource(string resourceName)
{
Logger.Instance.WriteMethodEntry();

try
{
var qualifiedResource = "AzureADConnectConfigDocumenter.Scripts." + resourceName;
using (StreamReader reader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(qualifiedResource)))
{
return reader.ReadToEnd();
}
}
finally
{
Logger.Instance.WriteMethodExit();
}
}

/// <summary>
/// Writes the documenter information.
/// </summary>
Expand Down Expand Up @@ -988,9 +987,9 @@ protected static void WriteDocumenterInfo(HtmlTextWriter htmlWriter)
htmlWriter.WriteBeginTag("a");
htmlWriter.WriteAttribute("style", "display: none;");
htmlWriter.WriteAttribute("href", "#");
htmlWriter.WriteAttribute("download", "SyncRuleChanges.ps1");
htmlWriter.WriteAttribute("id", "DownloadLink");
htmlWriter.WriteLine(HtmlTextWriter.TagRightChar);
htmlWriter.WriteAttribute("onclick", "return DownloadScript();");
htmlWriter.Write(HtmlTextWriter.TagRightChar);
htmlWriter.Write("Download Sync Rule Changes Script");
htmlWriter.WriteEndTag("a");

Expand Down Expand Up @@ -1054,6 +1053,13 @@ protected static void WriteDocumenterInfo(HtmlTextWriter htmlWriter)
htmlWriter.WriteLine(HtmlTextWriter.SelfClosingTagEnd);
}

htmlWriter.WriteBeginTag("div");
htmlWriter.WriteAttribute("class", "PowerShellScript");
htmlWriter.Write(HtmlTextWriter.TagRightChar);
htmlWriter.WriteLine(Documenter.GetEmbeddedScriptResource("PowerShellScriptHeader.ps1"));
htmlWriter.WriteLine();
htmlWriter.WriteEndTag("div");

htmlWriter.WriteLine();
}
finally
Expand Down
Loading

0 comments on commit a95986c

Please sign in to comment.