Skip to content

Commit

Permalink
Release 1.1.2158
Browse files Browse the repository at this point in the history
  • Loading branch information
sorengranfeldt committed May 2, 2018
1 parent a0be09d commit ed91dad
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 8 deletions.
2 changes: 1 addition & 1 deletion fim.mare/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly: AssemblyVersion("1.1.1500.*")]
[assembly: AssemblyVersion("1.1.2158.*")]

//
// In order to sign your assembly you must specify a key to use. Refer to the
Expand Down
15 changes: 15 additions & 0 deletions fim.mare/FIM.MARE.config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<ExternalFiles>
<XmlFile Name="CountryCodes" Path="C:\temp\CountryCodes.xml" />
</ExternalFiles>

<ManagementAgent Name="ad">

<Deprovision DefaultAction="Disconnect">
Expand Down Expand Up @@ -34,6 +35,20 @@
</SourceExpression>
</JoinRule>

<FlowRule Name="UserAccountControl" Direction="Export" xsi:type="FlowRule">
<Conditions Operator="And">
<Condition xsi:type="SourceValueMatch" Source="MVEntry" AttributeName="accountName" Pattern="^SG$" />
</Conditions>
<SourceExpression>
<Source Name="userAccountControl" xsi:type="Attribute" RetrieveFrom="CS">
<Transforms>
<Transform xsi:type="SetBit" BitPosition="1" Value="true" />
</Transforms>
</Source>
</SourceExpression>
<Target Name="userAccountControl" ActionOnNullSource="None" />
</FlowRule>

<FlowRule Name="cleanedProxyAddresses" Direction="Import" xsi:type="FlowRule">
<SourceExpression>
<Source Name="proxyAddresses" xsi:type="MultiValueAttribute">
Expand Down
2 changes: 1 addition & 1 deletion fim.mare/FIM.MARE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public void MapAttributesForImportExportDetached(string FlowRuleName, CSEntry cs
if (rules == null) throw new NotImplementedException(direction.ToString() + "-rule-'" + FlowRuleName + "'-not-found-on-ma-" + maName);
foreach (FlowRule r in rules) Tracer.TraceInformation("found-rule name: {0}, description: {1}", r.Name, r.Description);
FlowRule rule = rules.Where(ru => ru.Conditions.AreMet(csentry, mventry)).FirstOrDefault();
if (rule == null) throw new DeclineMappingException("no-" + direction.ToString() + "-rule-'" + FlowRuleName + "'-not-found-on-ma-'" + maName + "'-where-conditions-were-met");
if (rule == null) throw new DeclineMappingException("no-" + direction.ToString() + "-rule-'" + FlowRuleName + "'-found-on-ma-'" + maName + "'-where-conditions-were-met");

#region FlowRuleDefault
if (rule.GetType().Equals(typeof(FlowRule)))
Expand Down
1 change: 1 addition & 0 deletions fim.mare/FIM.MARE.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<Compile Include="Model\ManagementAgent.cs" />
<Compile Include="Model\Source.cs" />
<Compile Include="Model\Transforms.cs" />
<Compile Include="Model\Transforms\Transforms.DateTime.Add.cs" />
<Compile Include="Model\Transforms\Transforms.Not.cs" />
<Compile Include="Tracer.cs" />
</ItemGroup>
Expand Down
21 changes: 21 additions & 0 deletions fim.mare/Model/Source.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,31 @@ public class Attribute : Value
[XmlAttribute("Name")]
public string Name { get; set; }

[XmlAttribute("RetrieveFrom")]
public string RetrieveFrom { get; set; }

public string GetValueOrDefault(Direction direction, CSEntry csentry, MVEntry mventry)
{
string value = this.DefaultValue;
bool sourceValueIsPresent = false;
if (!string.IsNullOrEmpty(this.RetrieveFrom))
{
// override direction
switch (RetrieveFrom)
{
case "CS":
direction = Direction.Import;
Tracer.TraceInformation("retrieve-attribute-value-from: name: {0}, {1} / {2}", Name, direction, RetrieveFrom);
break;
case "MV":
direction = Direction.Export;
Tracer.TraceInformation("retrieve-attribute-value-from: name: {0}, {1} / {2}", Name, direction, RetrieveFrom);
break;
default:
Tracer.TraceWarning("override-source-input-value-to: INVALID (use CS or MV)");
break;
}
}
if (Name.Equals("[DN]") || Name.Equals("[RDN]") || Name.Equals("[ObjectType]") || Name.Equals("[ConnectionChangeTime]"))
{
sourceValueIsPresent = true;
Expand Down
14 changes: 8 additions & 6 deletions fim.mare/Model/Transforms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ namespace FIM.MARE
XmlInclude(typeof(RegexSelect)),
XmlInclude(typeof(RegexIsMatch)),
XmlInclude(typeof(FormatDate)),
XmlInclude(typeof(Base64ToGUID)),
XmlInclude(typeof(DateTimeAdd)),
XmlInclude(typeof(Base64ToGUID)),
XmlInclude(typeof(IsBitSet)),
XmlInclude(typeof(IsBitNotSet)),
XmlInclude(typeof(SIDToString)),
Expand Down Expand Up @@ -500,20 +501,21 @@ public class FormatDate : Transform
public override object Convert(object value)
{
if (value == null) return value;
string returnValue = value as string;
if (DateType.Equals(DateType.FileTimeUTC))
string returnValue = value.ToString();
Tracer.TraceInformation("formatdate-from {0} / {1}", DateType, returnValue);
if (DateType.Equals(DateType.FileTimeUTC))
{
returnValue = DateTime.FromFileTimeUtc(long.Parse(value as string)).ToString(ToFormat);
returnValue = DateTime.FromFileTimeUtc(long.Parse(value.ToString())).ToString(ToFormat);
return returnValue;
}
if (DateType.Equals(DateType.BestGuess))
{
returnValue = DateTime.Parse(value as string, CultureInfo.InvariantCulture).ToString(ToFormat);
returnValue = DateTime.Parse(value.ToString(), CultureInfo.InvariantCulture).ToString(ToFormat);
return returnValue;
}
if (DateType.Equals(DateType.DateTime))
{
returnValue = DateTime.ParseExact(value as string, FromFormat, CultureInfo.InvariantCulture).ToString(ToFormat);
returnValue = DateTime.ParseExact(value.ToString(), FromFormat, CultureInfo.InvariantCulture).ToString(ToFormat);
return returnValue;
}
return returnValue;
Expand Down
80 changes: 80 additions & 0 deletions fim.mare/Model/Transforms/Transforms.DateTime.Add.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// may 2, 2018 | soren granfeldt
// - added DateTimeAdd transform

using Microsoft.MetadirectoryServices;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Security.Principal;
using System.Text.RegularExpressions;
using System.Xml.Serialization;

namespace FIM.MARE
{

public class DateTimeAdd : Transform
{
[XmlAttribute("AddSeconds")]
public int AddSeconds { get; set; }
[XmlAttribute("AddMinutes")]
public int AddMinutes { get; set; }
[XmlAttribute("AddHours")]
public int AddHours { get; set; }
[XmlAttribute("AddDays")]
public int AddDays { get; set; }
[XmlAttribute("AddMonths")]
public int AddMonths { get; set; }
[XmlAttribute("AddYears")]
public int AddYears { get; set; }

public override object Convert(object value)
{
if (value == null) return value;
string input = value.ToString();
Tracer.TraceInformation("adddays {0}", AddDays);
DateTime dateValue;
if (DateTime.TryParse(input, out dateValue))
{
if (!AddSeconds.Equals(0))
{
dateValue = dateValue.AddSeconds(this.AddSeconds);
Tracer.TraceInformation("date-after-addseconds {0}", dateValue);
}
if (!AddMinutes.Equals(0))
{
dateValue = dateValue.AddMinutes(this.AddMinutes);
Tracer.TraceInformation("date-after-addminutes {0}", dateValue);
}
if (!AddHours.Equals(0))
{
dateValue = dateValue.AddHours(this.AddHours);
Tracer.TraceInformation("date-after-addhours {0}", dateValue);
}
if (!AddDays.Equals(0))
{
dateValue = dateValue.AddDays(this.AddDays);
Tracer.TraceInformation("date-after-adddays {0}", dateValue);
}
if (!AddMonths.Equals(0))
{
dateValue = dateValue.AddMonths(this.AddMonths);
Tracer.TraceInformation("date-after-addmonths {0}", dateValue);
}
if (!AddYears.Equals(0))
{
dateValue = dateValue.AddYears(this.AddYears);
Tracer.TraceInformation("date-after-addyears {0}", dateValue);
}
return dateValue;
}
else
{
Tracer.TraceWarning("could-not-parse-to-date {0}", 1, input);
}
return value;
}
}

}

0 comments on commit ed91dad

Please sign in to comment.