Granfeldt_cp 2013-01-15 11:21:20 -08:00
parent 15627640ff
commit 87c71262e0
36 changed files with 1993 additions and 0 deletions

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:mime-type</Name><Value>application/octet-stream</Value></Property></Properties></ItemProperties>

View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Granfeldt.FIM.ActivityLibrary", "Granfeldt.FIM.ActivityLibrary\Granfeldt.FIM.ActivityLibrary.csproj", "{30020462-9E9D-47AB-B63D-C01B5CA6445E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{30020462-9E9D-47AB-B63D-C01B5CA6445E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30020462-9E9D-47AB-B63D-C01B5CA6445E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30020462-9E9D-47AB-B63D-C01B5CA6445E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30020462-9E9D-47AB-B63D-C01B5CA6445E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Binary file not shown.

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:mime-type</Name><Value>application/octet-stream</Value></Property></Properties></ItemProperties>

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:mime-type</Name><Value>application/octet-stream</Value></Property></Properties></ItemProperties>

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:mime-type</Name><Value>application/octet-stream</Value></Property></Properties></ItemProperties>

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:mime-type</Name><Value>application/octet-stream</Value></Property></Properties></ItemProperties>

View File

@ -0,0 +1,291 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Reflection;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class CodeActivity
{
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
[System.CodeDom.Compiler.GeneratedCode("", "")]
private void InitializeComponent()
{
this.CanModifyActivities = true;
System.Workflow.Activities.CodeCondition codecondition1 = new System.Workflow.Activities.CodeCondition();
System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind2 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.Activities.CodeCondition codecondition2 = new System.Workflow.Activities.CodeCondition();
System.Workflow.Activities.CodeCondition codecondition3 = new System.Workflow.Activities.CodeCondition();
this.CatchAndArgumentException = new System.Workflow.Activities.CodeActivity();
this.faultHandlerActivity1 = new System.Workflow.ComponentModel.FaultHandlerActivity();
this.faultHandlersActivity3 = new System.Workflow.ComponentModel.FaultHandlersActivity();
this.UpdateTargetResource = new Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity();
this.NoUpdateNeeded = new System.Workflow.Activities.IfElseBranchActivity();
this.UpdateTarget = new System.Workflow.Activities.IfElseBranchActivity();
this.NullOrInvalidGrammar = new System.Workflow.Activities.CodeActivity();
this.CompareAndPrepareUpdate = new System.Workflow.Activities.IfElseActivity();
this.ReadTarget = new Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity();
this.faultHandlerActivity2 = new System.Workflow.ComponentModel.FaultHandlerActivity();
this.ExitGracefully = new System.Workflow.Activities.CodeActivity();
this.UpdateIfNecessary = new System.Workflow.Activities.SequenceActivity();
this.faultHandlersActivity2 = new System.Workflow.ComponentModel.FaultHandlersActivity();
this.SaveResolvedParameterValue = new System.Workflow.Activities.CodeActivity();
this.ResolveParameterValue = new Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity();
this.UpdateWorkflowData = new System.Workflow.Activities.IfElseBranchActivity();
this.ConditionalUpdateTarget = new System.Workflow.Activities.IfElseBranchActivity();
this.faultHandlersActivity1 = new System.Workflow.ComponentModel.FaultHandlersActivity();
this.ResolveAndSave = new System.Workflow.Activities.SequenceActivity();
this.ShouldUpdateTarget = new System.Workflow.Activities.IfElseActivity();
this.ExecuteCode = new System.Workflow.Activities.CodeActivity();
this.CompileCode = new System.Workflow.Activities.CodeActivity();
this.ResolveAllParameters = new System.Workflow.Activities.WhileActivity();
//
// CatchAndArgumentException
//
this.CatchAndArgumentException.Name = "CatchAndArgumentException";
this.CatchAndArgumentException.ExecuteCode += new System.EventHandler(this.CatchArgumentException_ExecuteCode);
//
// faultHandlerActivity1
//
this.faultHandlerActivity1.Activities.Add(this.CatchAndArgumentException);
this.faultHandlerActivity1.FaultType = typeof(System.ArgumentNullException);
this.faultHandlerActivity1.Name = "faultHandlerActivity1";
//
// faultHandlersActivity3
//
this.faultHandlersActivity3.Activities.Add(this.faultHandlerActivity1);
this.faultHandlersActivity3.Name = "faultHandlersActivity3";
//
// UpdateTargetResource
//
this.UpdateTargetResource.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.UpdateTargetResource.ApplyAuthorizationPolicy = false;
this.UpdateTargetResource.Name = "UpdateTargetResource";
this.UpdateTargetResource.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.UpdateTargetResource.UpdateParameters = null;
//
// NoUpdateNeeded
//
this.NoUpdateNeeded.Name = "NoUpdateNeeded";
//
// UpdateTarget
//
this.UpdateTarget.Activities.Add(this.UpdateTargetResource);
this.UpdateTarget.Activities.Add(this.faultHandlersActivity3);
codecondition1.Condition += new System.EventHandler<System.Workflow.Activities.ConditionalEventArgs>(this.isTargetUpdateNeeded_Condition);
this.UpdateTarget.Condition = codecondition1;
this.UpdateTarget.Name = "UpdateTarget";
//
// NullOrInvalidGrammar
//
this.NullOrInvalidGrammar.Name = "NullOrInvalidGrammar";
this.NullOrInvalidGrammar.ExecuteCode += new System.EventHandler(this.NonExistingGrammarException_ExecuteCode);
//
// CompareAndPrepareUpdate
//
this.CompareAndPrepareUpdate.Activities.Add(this.UpdateTarget);
this.CompareAndPrepareUpdate.Activities.Add(this.NoUpdateNeeded);
this.CompareAndPrepareUpdate.Name = "CompareAndPrepareUpdate";
//
// ReadTarget
//
this.ReadTarget.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.ReadTarget.Name = "ReadTarget";
activitybind1.Name = "CodeActivity";
activitybind1.Path = "TargetResource";
this.ReadTarget.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.ReadTarget.SelectionAttributes = null;
this.ReadTarget.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity.ResourceProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
//
// faultHandlerActivity2
//
this.faultHandlerActivity2.Activities.Add(this.NullOrInvalidGrammar);
this.faultHandlerActivity2.FaultType = typeof(System.ArgumentException);
this.faultHandlerActivity2.Name = "faultHandlerActivity2";
//
// ExitGracefully
//
this.ExitGracefully.Name = "ExitGracefully";
this.ExitGracefully.ExecuteCode += new System.EventHandler(this.ExitGracefully_ExecuteCode);
//
// UpdateIfNecessary
//
this.UpdateIfNecessary.Activities.Add(this.ReadTarget);
this.UpdateIfNecessary.Activities.Add(this.CompareAndPrepareUpdate);
this.UpdateIfNecessary.Name = "UpdateIfNecessary";
//
// faultHandlersActivity2
//
this.faultHandlersActivity2.Activities.Add(this.faultHandlerActivity2);
this.faultHandlersActivity2.Name = "faultHandlersActivity2";
//
// SaveResolvedParameterValue
//
this.SaveResolvedParameterValue.Name = "SaveResolvedParameterValue";
this.SaveResolvedParameterValue.ExecuteCode += new System.EventHandler(this.SaveResolvedValue_ExecuteCode);
//
// ResolveParameterValue
//
this.ResolveParameterValue.GrammarExpression = null;
this.ResolveParameterValue.Name = "ResolveParameterValue";
activitybind2.Name = "CodeActivity";
activitybind2.Path = "ResolvedParameterExpression";
this.ResolveParameterValue.WorkflowDictionaryKey = null;
this.ResolveParameterValue.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity.ResolvedExpressionProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind2)));
//
// UpdateWorkflowData
//
this.UpdateWorkflowData.Name = "UpdateWorkflowData";
//
// ConditionalUpdateTarget
//
this.ConditionalUpdateTarget.Activities.Add(this.UpdateIfNecessary);
this.ConditionalUpdateTarget.Activities.Add(this.ExitGracefully);
codecondition2.Condition += new System.EventHandler<System.Workflow.Activities.ConditionalEventArgs>(this.ShouldUpdateTarget_Condition);
this.ConditionalUpdateTarget.Condition = codecondition2;
this.ConditionalUpdateTarget.Name = "ConditionalUpdateTarget";
//
// faultHandlersActivity1
//
this.faultHandlersActivity1.Name = "faultHandlersActivity1";
//
// ResolveAndSave
//
this.ResolveAndSave.Activities.Add(this.ResolveParameterValue);
this.ResolveAndSave.Activities.Add(this.SaveResolvedParameterValue);
this.ResolveAndSave.Activities.Add(this.faultHandlersActivity2);
this.ResolveAndSave.Name = "ResolveAndSave";
//
// ShouldUpdateTarget
//
this.ShouldUpdateTarget.Activities.Add(this.ConditionalUpdateTarget);
this.ShouldUpdateTarget.Activities.Add(this.UpdateWorkflowData);
this.ShouldUpdateTarget.Name = "ShouldUpdateTarget";
//
// ExecuteCode
//
this.ExecuteCode.Name = "ExecuteCode";
this.ExecuteCode.ExecuteCode += new System.EventHandler(this.ExecuteCode_ExecuteCode);
//
// CompileCode
//
this.CompileCode.Name = "CompileCode";
this.CompileCode.ExecuteCode += new System.EventHandler(this.CompileCode_ExecuteCode);
//
// ResolveAllParameters
//
this.ResolveAllParameters.Activities.Add(this.ResolveAndSave);
this.ResolveAllParameters.Activities.Add(this.faultHandlersActivity1);
codecondition3.Condition += new System.EventHandler<System.Workflow.Activities.ConditionalEventArgs>(this.MoreParametersToResolve_Condition);
this.ResolveAllParameters.Condition = codecondition3;
this.ResolveAllParameters.Name = "ResolveAllParameters";
//
// CodeActivity
//
this.Activities.Add(this.ResolveAllParameters);
this.Activities.Add(this.CompileCode);
this.Activities.Add(this.ExecuteCode);
this.Activities.Add(this.ShouldUpdateTarget);
this.Name = "CodeActivity";
this.CanModifyActivities = false;
}
#endregion
private System.Workflow.Activities.CodeActivity CatchAndArgumentException;
private FaultHandlerActivity faultHandlerActivity1;
private FaultHandlersActivity faultHandlersActivity3;
private System.Workflow.Activities.CodeActivity ExitGracefully;
private Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity UpdateTargetResource;
private IfElseBranchActivity NoUpdateNeeded;
private IfElseBranchActivity UpdateTarget;
private IfElseActivity CompareAndPrepareUpdate;
private Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity ReadTarget;
private SequenceActivity UpdateIfNecessary;
private IfElseBranchActivity UpdateWorkflowData;
private IfElseBranchActivity ConditionalUpdateTarget;
private IfElseActivity ShouldUpdateTarget;
private FaultHandlersActivity faultHandlersActivity2;
private System.Workflow.Activities.CodeActivity NullOrInvalidGrammar;
private FaultHandlerActivity faultHandlerActivity2;
private System.Workflow.Activities.CodeActivity ExecuteCode;
private FaultHandlersActivity faultHandlersActivity1;
private System.Workflow.Activities.CodeActivity CompileCode;
private System.Workflow.Activities.CodeActivity SaveResolvedParameterValue;
private Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity ResolveParameterValue;
private SequenceActivity ResolveAndSave;
private WhileActivity ResolveAllParameters;
}
}

View File

@ -0,0 +1,122 @@
// January 15, 2013 | Soren Granfeldt (soren@granfeldt.dk)
// - initial version
using System.Web.UI.WebControls;
using System.Workflow.ComponentModel;
using Microsoft.IdentityManagement.WebUI.Controls;
using Microsoft.ResourceManagement.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary.WebUIs
{
class CodeActivitySettingsPart : BaseActivitySettingsPart
{
const string InstanceTitle = "Title";
const string References = "References";
const string Parameters = "Parameters";
const string Code = "Code";
const string Destination = "Destination";
/// <summary>
/// Creates a Table that contains the controls used by the activity UI
/// in the Workflow Designer of the FIM portal. Adds that Table to the
/// collection of Controls that defines each activity that can be selected
/// in the Workflow Designer of the FIM Portal. Calls the base class of
/// ActivitySettingsPart to render the controls in the UI.
/// </summary>
protected override void CreateChildControls()
{
Table controlLayoutTable;
controlLayoutTable = new Table();
//Width is set to 100% of the control size
controlLayoutTable.Width = Unit.Percentage(100.0);
controlLayoutTable.BorderWidth = 0;
controlLayoutTable.CellPadding = 2;
//Add a TableRow for each textbox in the UI
controlLayoutTable.Rows.Add(this.AddTableRowTextBox("Title:", "txt" + InstanceTitle, 400, 100, false, ""));
controlLayoutTable.Rows.Add(this.AddTableRowTextBox("References (DLL's):<br/><i>(please note that System.dll is added by default)</i>", "txt" + References, 400, 4000, true, "System.dll"));
controlLayoutTable.Rows.Add(this.AddTableRowTextBox("Parameters:<br/><i>(parameters are passed to the FIMDynamicFunction method in the shown order given here. Therefore, you should make sure that the function FIMDynamicFunction accepts the correct number of parameters and possible types)</i>", "txt" + Parameters, 400, 4000, true, ""));
controlLayoutTable.Rows.Add(this.AddTableRowTextBox("Code:<br/><i>(code must always contain a class named FIMDynamicClass with a function named FIMDynamicFunction)</i>", "txt" + Code, 400, 4000, true, ""));
controlLayoutTable.Rows.Add(this.AddTableRowTextBox("Destination:", "txt" + Destination, 400, 100, false, ""));
this.Controls.Add(controlLayoutTable);
base.CreateChildControls();
}
public override Activity GenerateActivityOnWorkflow(SequentialWorkflow workflow)
{
if (!this.ValidateInputs())
{
return null;
}
CodeActivity ThisActivity = new CodeActivity();
ThisActivity.Title = this.GetText("txt" + InstanceTitle);
ThisActivity.References = this.GetTextArray("txt" + References);
ThisActivity.Parameters = this.GetTextArray("txt" + Parameters);
ThisActivity.Code = this.GetText("txt" + Code);
ThisActivity.Destination = this.GetText("txt" + Destination);
return ThisActivity;
}
public override void LoadActivitySettings(Activity activity)
{
CodeActivity ThisActivity = activity as CodeActivity;
if (ThisActivity != null)
{
this.SetText("txt" + InstanceTitle, ThisActivity.Title);
this.SetTextArray("txt" + References, ThisActivity.References);
this.SetTextArray("txt" + Parameters, ThisActivity.Parameters);
this.SetText("txt" + Code, ThisActivity.Code);
this.SetText("txt" + Destination, ThisActivity.Destination);
}
}
public override ActivitySettingsPartData PersistSettings()
{
ActivitySettingsPartData data = new ActivitySettingsPartData();
data[InstanceTitle] = this.GetText("txt" + InstanceTitle);
data[References] = this.GetTextArray("txt" + References);
data[Parameters] = this.GetTextArray("txt" + Parameters);
data[Code] = this.GetText("txt" + Code);
data[Destination] = this.GetText("txt" + Destination);
return data;
}
public override void RestoreSettings(ActivitySettingsPartData data)
{
if (null != data)
{
this.SetText("txt" + InstanceTitle, (string)data[InstanceTitle]);
this.SetTextArray("txt" + References, (string[])data[References]);
this.SetTextArray("txt" + Parameters, (string[])data[Parameters]);
this.SetText("txt" + Code, (string)data[Code]);
this.SetText("txt" + Destination, (string)data[Destination]);
}
}
public override void SwitchMode(ActivitySettingsPartMode mode)
{
bool readOnly = (mode == ActivitySettingsPartMode.View);
this.SetTextBoxReadOnlyOption("txt" + InstanceTitle, readOnly);
this.SetTextBoxReadOnlyOption("txt" + References, readOnly);
this.SetTextBoxReadOnlyOption("txt" + Parameters, readOnly);
this.SetTextBoxReadOnlyOption("txt" + Code, readOnly);
this.SetTextBoxReadOnlyOption("txt" + Destination, readOnly);
}
public override string Title
{
get
{
return string.Format("Code: {0}", this.GetText("txt" + InstanceTitle));
}
}
public override bool ValidateInputs()
{
return true;
}
}
}

View File

@ -0,0 +1,348 @@
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Web;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using Microsoft.ResourceManagement.WebServices.WSResourceManagement;
using Microsoft.ResourceManagement.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class CodeActivity : SequenceActivity
{
#region Properties
public static DependencyProperty TargetResourceProperty = DependencyProperty.Register("TargetResource", typeof(Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType), typeof(Granfeldt.FIM.ActivityLibrary.CodeActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Parameters")]
public Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType TargetResource
{
get
{
return ((Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType)(base.GetValue(Granfeldt.FIM.ActivityLibrary.CodeActivity.TargetResourceProperty)));
}
set
{
base.SetValue(Granfeldt.FIM.ActivityLibrary.CodeActivity.TargetResourceProperty, value);
}
}
/// <summary>
/// The title of the current instance of the workflow
/// </summary>
public static DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(CodeActivity));
[Description("Title")]
[Category("Title Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string Title
{
get
{
return ((string)(base.GetValue(CodeActivity.TitleProperty)));
}
set
{
base.SetValue(CodeActivity.TitleProperty, value);
}
}
public static DependencyProperty ReferencesProperty = DependencyProperty.Register("References", typeof(string[]), typeof(CodeActivity));
[Description("References")]
[Category("References Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string[] References
{
get
{
return ((string[])(base.GetValue(CodeActivity.ReferencesProperty)));
}
set
{
base.SetValue(CodeActivity.ReferencesProperty, value);
}
}
public static DependencyProperty ParametersProperty = DependencyProperty.Register("Parameters", typeof(string[]), typeof(CodeActivity));
[Description("Parameters")]
[Category("Parameters Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string[] Parameters
{
get
{
return ((string[])(base.GetValue(CodeActivity.ParametersProperty)));
}
set
{
base.SetValue(CodeActivity.ParametersProperty, value);
}
}
public static DependencyProperty ResolvedParameterExpressionProperty = DependencyProperty.Register("ResolvedParameterExpression", typeof(System.String), typeof(Granfeldt.FIM.ActivityLibrary.CodeActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Misc")]
public String ResolvedParameterExpression
{
get
{
return ((string)(base.GetValue(Granfeldt.FIM.ActivityLibrary.CodeActivity.ResolvedParameterExpressionProperty)));
}
set
{
base.SetValue(Granfeldt.FIM.ActivityLibrary.CodeActivity.ResolvedParameterExpressionProperty, value);
}
}
public static DependencyProperty CodeProperty = DependencyProperty.Register("Code", typeof(string), typeof(CodeActivity));
[Description("Code")]
[Category("Code Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string Code
{
get
{
return ((string)(base.GetValue(CodeActivity.CodeProperty)));
}
set
{
base.SetValue(CodeActivity.CodeProperty, value);
}
}
public static DependencyProperty DestinationProperty = DependencyProperty.Register("Destination", typeof(string), typeof(CodeActivity));
[Description("Destination")]
[Category("Destination Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string Destination
{
get
{
return ((string)(base.GetValue(CodeActivity.DestinationProperty)));
}
set
{
base.SetValue(CodeActivity.DestinationProperty, value);
}
}
#endregion
/// <summary>
/// Contains in-memory compiled code
/// </summary>
private static object compiled = null;
/// <summary>
/// List of unresolved parameters
/// </summary>
List<string> UnresolvedParameters = null;
/// <summary>
/// List of resolved parameters. These are passed to the default code method
/// </summary>
List<object> ResolvedParameters = new List<object>();
/// <summary>
/// Reference to parent workflow
/// </summary>
SequentialWorkflow containingWorkflow = null;
string destinationObject = null;
string destinationAttribute = null;
public CodeActivity()
{
Debugging.Log("Enter :: Initialize");
InitializeComponent();
Debugging.Log("Exit :: Initialize");
}
/// <summary>
/// Has returned value from code function
/// </summary>
object codeReturnValue = null;
private void MoreParametersToResolve_Condition(object sender, ConditionalEventArgs e)
{
// we need to convert the string array to a list to
// be able to remove values
if (UnresolvedParameters == null)
{
UnresolvedParameters = this.Parameters.ToList();
Debugging.Log("Resolving parameters");
}
e.Result = false;
if (UnresolvedParameters.Count > 0)
{
this.ResolveParameterValue.GrammarExpression = UnresolvedParameters[0];
Debugging.Log("Resolving", UnresolvedParameters[0]);
UnresolvedParameters.RemoveAt(0);
e.Result = true;
}
}
private void SaveResolvedValue_ExecuteCode(object sender, EventArgs e)
{
ResolvedParameters.Add(HttpUtility.HtmlDecode(this.ResolveParameterValue.ResolvedExpression));
Debugging.Log("Resolved to", HttpUtility.HtmlDecode(this.ResolveParameterValue.ResolvedExpression));
}
private void NonExistingGrammarException_ExecuteCode(object sender, EventArgs e)
{
// if we get here, the resolve has failed. If the value that we're
// trying to resolve doesn't exist, we also get here. We
// assume that there is no value and set value to null
Debugging.Log("Missing value or invalid XPath reference (returning [null])", this.ResolveParameterValue.GrammarExpression);
ResolvedParameters.Add(null);
}
private void CompileCode_ExecuteCode(object sender, EventArgs e)
{
CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");
CompilerParameters compilerParameters = new CompilerParameters();
// DLL must exist in C:\Windows\Microsoft.NET\Framework64\v2.0.50727
foreach (string dll in this.References)
{
compilerParameters.ReferencedAssemblies.Add(dll);
}
if (compilerParameters.ReferencedAssemblies.Contains("System.dll"))
{
compilerParameters.ReferencedAssemblies.Add("System.dll");
}
compilerParameters.GenerateExecutable = false;
compilerParameters.GenerateInMemory = true;
compilerParameters.IncludeDebugInformation = false;
CompilerResults cr = provider.CompileAssemblyFromSource(compilerParameters, HttpUtility.HtmlDecode(this.Code));
if (cr.Errors.HasErrors)
{
StringBuilder compileErrors = new StringBuilder();
foreach (CompilerError ce in cr.Errors)
{
compileErrors.AppendFormat("Compile Error: {0} in Ln {2} Col {3}-{1}\r\n", ce.ErrorNumber, ce.ErrorText, ce.Line, ce.Column);
}
Debugging.Log(new Exception("Couldn't compile\r\n" + compileErrors));
}
Assembly assembly = cr.CompiledAssembly;
compiled = assembly.CreateInstance("FIMDynamicClass");
}
private void ExecuteCode_ExecuteCode(object sender, EventArgs e)
{
if (compiled == null)
{
Debugging.Log(new NullReferenceException("Code must contain a class named FIMDynamicClass and that class must contain a method called FIMDynamicFunction"));
}
Debugging.Log("Parameter count", ResolvedParameters.Count);
foreach (object param in ResolvedParameters)
{
Debugging.Log("Adding parameter", param);
}
MethodInfo mi = compiled.GetType().GetMethod("FIMDynamicFunction");
Debugging.Log("Executing code");
codeReturnValue = mi.Invoke(compiled, ResolvedParameters.ToArray());
Debugging.Log("Code executed");
Debugging.Log("Code return value", codeReturnValue);
}
private void ShouldUpdateTarget_Condition(object sender, ConditionalEventArgs e)
{
// try to get parent workflow.
if (!SequentialWorkflow.TryGetContainingWorkflow(this, out containingWorkflow))
{
throw new InvalidOperationException("Could not get parent workflow");
}
StringUtilities.ExtractWorkflowExpression(this.Destination, out destinationObject, out destinationAttribute);
if (!string.IsNullOrEmpty(destinationAttribute))
{
if (destinationObject.Equals("WorkflowData", StringComparison.OrdinalIgnoreCase))
{
e.Result = false;
if (containingWorkflow != null)
{
containingWorkflow.WorkflowDictionary.Add(destinationAttribute, codeReturnValue);
}
}
else if (destinationObject.Equals("Target", StringComparison.OrdinalIgnoreCase))
{
e.Result = true;
ReadTarget.ActorId = WellKnownGuids.FIMServiceAccount;
ReadTarget.ResourceId = containingWorkflow.TargetId;
ReadTarget.SelectionAttributes = new string[] { destinationAttribute };
}
}
else
{
Debugging.Log(new Exception("Could not resolved destination. Please specify as [//Target/Attribute] or [//WorkflowData/Parameter]"));
}
}
private void isTargetUpdateNeeded_Condition(object sender, ConditionalEventArgs e)
{
List<UpdateRequestParameter> updateParameters = new List<UpdateRequestParameter>();
e.Result = false;
object currentValue = TargetResource[destinationAttribute];
if (object.Equals(currentValue, codeReturnValue))
{
Debugging.Log(string.Format("No need to update {0}. Value is already '{1}'", destinationAttribute, codeReturnValue));
}
else
{
e.Result = true;
// if code returns null then remove current value; otherwise
// update to new value
updateParameters.Add(new UpdateRequestParameter(destinationAttribute, codeReturnValue == null ? UpdateMode.Remove : UpdateMode.Modify, codeReturnValue == null ? currentValue : codeReturnValue));
Debugging.Log("Updating", containingWorkflow.TargetId);
UpdateTargetResource.ActorId = WellKnownGuids.FIMServiceAccount;
UpdateTargetResource.ResourceId = containingWorkflow.TargetId;
UpdateTargetResource.UpdateParameters = updateParameters.ToArray();
if (codeReturnValue == null)
{
Debugging.Log(string.Format("Removing existing value '{0}' from {1}", currentValue, destinationAttribute));
}
else
{
Debugging.Log(string.Format("Updating {0} from '{1}' to '{2}'", destinationAttribute, currentValue == null ? "(null)" : currentValue, codeReturnValue == null ? "(null)" : codeReturnValue));
}
}
}
private void CatchArgumentException_ExecuteCode(object sender, EventArgs e)
{
// if we get here, the resolve has failed. If the value that we're
// trying to resolve doesn't exist, we also get here. We
// assume that there is no value and set source value to null
// which effectively results in a 'Delete' operation on
// the target attribute value (if present)
Debugging.Log("Error: Argument Exception");
}
private void ExitGracefully_ExecuteCode(object sender, EventArgs e)
{
Debugging.Log("Activity exited");
}
}
}

View File

@ -0,0 +1,10 @@
using System;
using System.Text.RegularExpressions;
public class FIMDynamicClass
{
public object FIMDynamicFunction(object displayname, string pattern, string replacement)
{
return Regex.Replace((string)displayname, pattern, replacement, RegexOptions.IgnoreCase);
}
}

View File

@ -0,0 +1,73 @@
<#
.SYNOPSIS
Installing Assemblies to Global Assembly Cache (GAC)
.DESCRIPTION
This script is an alternative to the GACUTIL available in
the .NET Framework SDK. It will put the specified assembly
in the GAC.
.EXAMPLE
.\Add-AssemblyToGlobalAssemblyCache.ps1 -AssemblyName C:\Temp\MyWorkflow.dll
This command will install the file MyWorkflow.dll from the C:\Temp directory in the GAC.
.EXAMPLE
Dir C:\MyWorkflowAssemblies | % {$_.Fullname} | .\Add-AssemblyToGlobalAssemblyCache.ps1
You can also pass the assembly filenames through the pipeline making it easy
to install several assemblies in one run. The command abobe will install
all assemblies from the directory C:\MyWorkflowAssemblies, run this command -
.PARAMETER AssemblyName
Full path of the assembly file
.NOTES
April 18, 2012 | Soren Granfeldt (soren@granfeldt.dk)
- initial version
.LINK
http://blog.goverco.com
#>
[CmdletBinding()]
PARAM
(
[Parameter(Mandatory=$true, ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]
[ValidateNotNullOrEmpty()]
[string] $AssemblyName = "",
[switch]$PassThru
)
BEGIN
{
$me = $MyInvocation.MyCommand -Replace '\.ps1$', ''
Write-Debug "BEGIN: $Me"
if ( $null -eq ([AppDomain]::CurrentDomain.GetAssemblies() |? { $_.FullName -eq "System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" }) ) {
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") | Out-Null
}
$PublishObject = New-Object System.EnterpriseServices.Internal.Publish
}
PROCESS {
Write-Debug "PROCESS: $me"
foreach ($Assembly in $AssemblyName)
{
if ( -not (Test-Path $Assembly -type Leaf) )
{
throw "The assembly '$Assembly' does not exist."
}
$LoadedAssembly = [System.Reflection.Assembly]::LoadFile($Assembly)
if ($LoadedAssembly.GetName().GetPublicKey().Length -eq 0)
{
throw "The assembly '$Assembly' must be strongly signed."
}
Write-Verbose "Installing: $Assembly"
$PublishObject.GacInstall($Assembly)
if ($PassThru) { $_ }
}
}
END
{
Write-Debug "END: $me"
}

View File

@ -0,0 +1,286 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.Workflow.ComponentModel;
using Microsoft.IdentityManagement.WebUI.Controls;
using Microsoft.ResourceManagement.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary
{
class BaseActivitySettingsPart : ActivitySettingsPart
{
#region Utility Functions
/// <summary>
/// Create a TableRow that contains a label and a textbox.
/// </summary>
protected TableRow AddTableRowTextBox(String labelText, String controlID, int width, int maxLength, Boolean multiLine, String defaultValue)
{
TableRow row = new TableRow();
TableCell labelCell = new TableCell();
TableCell controlCell = new TableCell();
Label oLabel = new Label();
TextBox oText = new TextBox();
oLabel.Text = labelText;
oLabel.CssClass = base.LabelCssClass;
labelCell.Controls.Add(oLabel);
oText.ID = controlID;
oText.CssClass = base.TextBoxCssClass;
oText.Text = defaultValue;
oText.MaxLength = maxLength;
oText.Width = width;
if (multiLine)
{
oText.TextMode = TextBoxMode.MultiLine;
oText.Rows = System.Math.Min(6, (maxLength + 60) / 60);
oText.Wrap = true;
}
controlCell.Controls.Add(oText);
row.Cells.Add(labelCell);
row.Cells.Add(controlCell);
return row;
}
protected TableRow AddDropDownList(String labelText, String controlID, int width, String defaultValue)
{
Debugging.Log("Enter AddDropDownList");
TableRow row = new TableRow();
TableCell labelCell = new TableCell();
TableCell controlCell = new TableCell();
// Add label
Label oLabel = new Label();
oLabel.Text = labelText;
oLabel.CssClass = base.LabelCssClass;
labelCell.Controls.Add(oLabel);
DropDownList ddl = new DropDownList();
ddl.ID = controlID;
//ddl.CssClass = base.???cssclass
ddl.Width = width;
ListItem BuiltInSynchronizationAccount = new ListItem("Built-in Synchronization Account", WellKnownGuids.BuiltInSynchronizationAccount.ToString());
ListItem FIMServiceAccount = new ListItem("FIMServiceAccount", WellKnownGuids.FIMServiceAccount.ToString());
ListItem Anonymous = new ListItem("Anonymous", WellKnownGuids.Anonymous.ToString());
ddl.Items.Add(BuiltInSynchronizationAccount);
ddl.Items.Add(FIMServiceAccount);
ddl.Items.Add(Anonymous);
ddl.SelectedValue = defaultValue;
controlCell.Controls.Add(ddl);
row.Cells.Add(labelCell);
row.Cells.Add(controlCell);
Debugging.Log("Leave AddDropDownList");
return row;
}
protected TableRow AddCheckbox(String labelText, String controlID, bool defaultValue)
{
Debugging.Log("Enter AddCheckbox");
TableRow row = new TableRow();
TableCell labelCell = new TableCell();
TableCell controlCell = new TableCell();
// Add label
Label oLabel = new Label();
oLabel.Text = labelText;
oLabel.CssClass = base.LabelCssClass;
labelCell.Controls.Add(oLabel);
CheckBox cb = new CheckBox();
cb.ID = controlID;
cb.Checked = defaultValue;
controlCell.Controls.Add(cb);
row.Cells.Add(labelCell);
row.Cells.Add(controlCell);
Debugging.Log("Leave AddCheckbox");
return row;
}
protected bool GetCheckbox(string checkBoxID)
{
CheckBox checkBox = (CheckBox)this.FindControl(checkBoxID);
if (checkBox != null)
return checkBox.Checked;
else
return false;
}
protected void SetCheckbox(string checkBoxID, bool isChecked)
{
CheckBox checkBox = (CheckBox)this.FindControl(checkBoxID);
if (checkBox != null)
{
checkBox.Checked = isChecked;
}
}
protected string GetText(string textBoxID)
{
TextBox textBox = (TextBox)this.FindControl(textBoxID);
return textBox.Text ?? String.Empty;
}
protected void SetText(string textBoxID, string text)
{
TextBox textBox = (TextBox)this.FindControl(textBoxID);
if (textBox != null)
textBox.Text = text;
else
textBox.Text = "";
}
protected string[] GetTextArray(string textBoxId)
{
TextBox textBox = (TextBox)this.FindControl(textBoxId);
string[] words = textBox.Text.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
return words ?? null;
}
protected void SetTextArray(string textBoxID, string[] text)
{
TextBox textBox = (TextBox)this.FindControl(textBoxID);
StringBuilder myBuilder = new StringBuilder();
foreach (string s in text)
{
if (!String.IsNullOrEmpty(s))
myBuilder.AppendLine(s);
}
string toInsert = myBuilder.ToString().TrimEnd('\r', '\n');
textBox.Text = toInsert;
}
//Set the text box to read mode or read/write mode
protected void SetCheckboxReadOnlyOption(string CheckBoxID, bool readOnly)
{
CheckBox checkBox = (CheckBox)this.FindControl(CheckBoxID);
checkBox.Enabled = !readOnly;
}
//Set the check box to read mode or read/write mode
protected void SetTextBoxReadOnlyOption(string textBoxID, bool readOnly)
{
TextBox textBox = (TextBox)this.FindControl(textBoxID);
textBox.Enabled = !readOnly;
}
string GetDropDownList(string dropDownListID)
{
Debugging.Log("Enter GetDropDownList");
string g = WellKnownGuids.FIMServiceAccount.ToString();
DropDownList ddl = (DropDownList)this.FindControl(dropDownListID);
if (ddl != null)
{
if (!string.IsNullOrEmpty(ddl.SelectedValue))
g = ddl.SelectedValue.ToString();
}
else
Debugging.Log("Cannot find control with ID '" + dropDownListID + "'");
Debugging.Log("Leave GetDropDownList");
return g;
}
void SetDropDownList(string dropDownListID, object Guid)
{
Debugging.Log("Enter SetDropDownList");
DropDownList ddl = (DropDownList)this.FindControl(dropDownListID);
if (ddl != null)
{
if (Guid != null)
ddl.SelectedValue = Guid.ToString();
}
else
Debugging.Log("Cannot find control with ID '" + dropDownListID + "'");
Debugging.Log("Leave SetDropDownList");
}
void SetDropDownListEnabled(string dropDownListID, bool enabled)
{
Debugging.Log("Enter SetDropDownListEnabled");
DropDownList ddl = (DropDownList)this.FindControl(dropDownListID);
if (ddl != null)
{
ddl.Enabled = enabled;
}
Debugging.Log("Leave SetDropDownListEnabled");
}
#endregion
/// <summary>
/// Called when a user clicks the Save button in the Workflow Designer.
/// Returns an instance of the RequestLoggingActivity class that
/// has its properties set to the values entered into the text box controls
/// used in the UI of the activity.
/// </summary>
public override Activity GenerateActivityOnWorkflow(SequentialWorkflow workflow)
{
throw new NotImplementedException();
}
/// <summary>
/// Called by FIM when the UI for the activity must be reloaded.
/// It passes us an instance of our workflow activity so that we can
/// extract the values of the properties to display in the UI.
/// </summary>
public override void LoadActivitySettings(Activity activity)
{
throw new NotImplementedException();
}
/// <summary>
/// Saves the activity settings.
/// </summary>
public override ActivitySettingsPartData PersistSettings()
{
throw new NotImplementedException();
}
/// <summary>
/// Restores the activity settings in the UI
/// </summary>
public override void RestoreSettings(ActivitySettingsPartData data)
{
throw new NotImplementedException();
}
/// <summary>
/// Switches the activity between read only and read/write mode
/// </summary>
public override void SwitchMode(ActivitySettingsPartMode mode)
{
throw new NotImplementedException();
}
/// <summary>
/// Returns the activity name.
/// </summary>
public override string Title
{
get { throw new NotImplementedException(); }
}
/// <summary>
/// In general, this method should be used to validate information entered
/// by the user when the activity is added to a workflow in the Workflow
/// Designer.
/// We could add code to verify that the log file path already exists on
/// the server that is hosting the FIM Portal and check that the activity
/// has permission to write to that location. However, the code
/// would only check if the log file path exists when the
/// activity is added to a workflow in the workflow designer. This class
/// will not be used when the activity is actually run.
/// For this activity we will just return true.
/// </summary>
public override bool ValidateInputs()
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,102 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Reflection;
using System.Threading;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace Granfeldt.FIM.ActivityLibrary
{
public class WellKnownGuids
{
public static Guid BuiltInSynchronizationAccount = new Guid("fb89aefa-5ea1-47f1-8890-abe7797d6497");
public static Guid FIMServiceAccount = new Guid("e05d1f1b-3d5e-4014-baa6-94dee7d68c89");
public static Guid Anonymous = new Guid("b0b36673-d43b-4cfa-a7a2-aff14fd90522");
}
public static class Debugging
{
private static string DebugLogFilename = null;
private static Mutex loggingMutex = new Mutex();
static Debugging()
{
try
{
DebugLogFilename = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Granfeldt\FIM\Workflows", false).GetValue("DebugLogFilename", null).ToString();
DebugLogFilename = string.Format(DebugLogFilename, DateTime.Now);
}
catch
{
// we get here if key og hive doesn't exist
}
}
public static void Log(string s)
{
string message = string.Format("{0}: {1}", DateTime.Now, string.IsNullOrEmpty(s) ? "(null)" : s);
loggingMutex.WaitOne();
if (!string.IsNullOrEmpty(DebugLogFilename))
{
using (StreamWriter f = new StreamWriter(DebugLogFilename, true))
{
f.WriteLine(message);
}
}
loggingMutex.ReleaseMutex();
System.Diagnostics.Trace.WriteLine(string.Format("{0}: {1} - {2}", DateTime.Now, s, TraceRoutine("")));
}
public static void Log(string name, object value)
{
Log(string.Format("{0}: {1}", name, value != null ? value.ToString() : "(null)"));
}
public static void Log(Exception ex)
{
Log(string.Format("Error: {0}", ex.Message));
throw ex;
}
public static string TraceRoutine(string action)
{
StackTrace CallStack = new StackTrace();
int i = 0;
string StrOut = null;
for (i = CallStack.FrameCount - 1; i >= 1; i += -1)
{
if (StrOut != null)
{
StrOut += "->";
}
StrOut += CallStack.GetFrame(i).GetMethod().Name;
}
CallStack = null;
return string.Format("{0}: {1}", action, StrOut);
}
}
public class StringUtilities
{
/// <summary>
/// Parses and splits the expression passed
/// </summary>
/// <param name="Expression">Expression to parse, i.e. [//Target/DisplayName] or [//WorkflowData/Password]</param>
/// <param name="Destination">Will hold the destination object type after parsing</param>
/// <param name="DestinationAttribute">Will hold the destination attribute after parsing</param>
/// <returns></returns>
public static void ExtractWorkflowExpression(string Expression, out string Destination, out string DestinationAttribute)
{
Regex regex = new Regex(@"^\[//(?<destination>\w+)/+?(?<destinationattribute>\w*[^]])", RegexOptions.IgnoreCase);
Destination = regex.Match(Expression).Result("${destination}");
DestinationAttribute = regex.Match(Expression).Result("${destinationattribute}");
}
}
}

View File

@ -0,0 +1,73 @@
# April 17, 2012 | Soren Granfeldt (soren@granfeldt.dk)
# - initial version
#----------------------------------------------------------------------------------------------------------
function Get-FIMResource
{
PARAM($Filter, $Uri = $DefaultUri)
END
{
$resources = Export-FIMConfig -CustomConfig $Filter -Uri $Uri
$resources
}
}
#----------------------------------------------------------------------------------------------------------
function Get-FIMResourceObjectID
{
PARAM($Filter, $Uri, $FilterObjectType)
END
{
$resources = Export-FIMConfig -CustomConfig $Filter -Uri $Uri
if ($FilterObjectType)
{
$resources = $resources | ? { $_.ResourceManagementObject.ObjectType -imatch $FilterObjectType}
}
[Microsoft.ResourceManagement.Automation.ObjectModel.ExportObject] $ObjectID = $resources | Select -First 1
$ObjectID.ResourceManagementObject.ObjectIdentifier
}
}
#----------------------------------------------------------------------------------------------------------
Function Set-FIMAttribute
{
Param($object, $attributeName, $attributeValue)
End
{
$importChange = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportChange
$importChange.Operation = 1
$importChange.AttributeName = $attributeName
$importChange.AttributeValue = $attributeValue
$importChange.FullyResolved = 1
$importChange.Locale = "Invariant"
If ($object.Changes -eq $null) {$object.Changes = (,$importChange)}
Else {$object.Changes += $importChange}
}
}
#----------------------------------------------------------------------------------------------------------
Function New-FIMImportObject
{
Param($objectType)
End
{
$newObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject
$newObject.ObjectType = $objectType
$newObject.SourceObjectIdentifier = [System.Guid]::NewGuid().ToString()
$newObject
}
}
#----------------------------------------------------------------------------------------------------------
Function Add-FIMMultiValue
{
Param($object, $attributeName, $attributeValue)
End
{
$importChange = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportChange
$importChange.Operation = 0
$importChange.AttributeName = $attributeName
$importChange.AttributeValue = $attributeValue
$importChange.FullyResolved = 1
$importChange.Locale = "Invariant"
If ($object.Changes -eq $null) {$object.Changes = (,$importChange)}
Else {$object.Changes += $importChange}
}
}

View File

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<ProductVersion>9.0.21107</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{30020462-9E9D-47AB-B63D-C01B5CA6445E}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Granfeldt.FIM.ActivityLibrary</RootNamespace>
<AssemblyName>Granfeldt.FIM.ActivityLibrary</AssemblyName>
<ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>.\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>false</DebugSymbols>
<Optimize>true</Optimize>
<OutputPath>.\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>Granfeldt.FIM.ActivityLibrary.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.IdentityManagement.Activities, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Microsoft.IdentityManagement.Activities.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityManagement.SettingsContract">
<HintPath>..\..\..\..\..\..\Program Files\Microsoft Forefront Identity Manager\2010\Service\Microsoft.IdentityManagement.SettingsContract.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.IdentityManagement.WebUI.Controls, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Microsoft.IdentityManagement.WebUI.Controls.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityManagement.WFExtensionInterfaces, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Microsoft.IdentityManagement.WFExtensionInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ResourceManagement, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files\Microsoft Forefront Identity Manager\2010\Service\Microsoft.ResourceManagement.dll</HintPath>
</Reference>
<Reference Include="System.Workflow.Activities" />
<Reference Include="System.Workflow.ComponentModel" />
<Reference Include="System.Workflow.Runtime" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Services" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="Activity.Code\Activity.Code.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Activity.Code\Activity.Code.Designer.cs">
<DependentUpon>Activity.Code.cs</DependentUpon>
</Compile>
<Compile Include="Base.Classes\Base.ActivitySettings.cs" />
<Compile Include="Base.Classes\Base.HelperClasses.cs" />
<Compile Include="Activity.Code\Activity.Code.SettingsPart.cs" />
<Content Include="Activity.Code\CodeActivity.sample.regex.txt" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<None Include="Add-AssemblyToGlobalAssemblyCache.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="FIM2010-Module.psm1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Granfeldt.FIM.ActivityLibrary.snk" />
<None Include="Install-Workflows.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="New-FIMActivityInformationConfigurationObject.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
<None Include="Reinstall.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.Targets" />
<Import Project="$(MSBuildToolsPath)\Workflow.Targets" />
</Project>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,39 @@
PARAM
(
[string] $AssemblyName = "Granfeldt.FIM.ActivityLibrary.dll",
[switch] $CreateCodeActivity
)
BEGIN
{
if ( $null -eq ([AppDomain]::CurrentDomain.GetAssemblies() |? { $_.FullName -eq "System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" }) ) {
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") | Out-Null
}
}
PROCESS
{
(Join-Path $PWD $AssemblyName) | .\Add-AssemblyToGlobalAssemblyCache.ps1
$LoadedAssembly = [System.Reflection.Assembly]::LoadFile( (Resolve-Path $AssemblyName).Path )
$ManifestModule = $LoadedAssembly.ManifestModule -replace '\.dll$'
if ($CreateCodeActivity)
{
$Params = @{ `
DisplayName = 'Code Activity'
Description = 'Execute C# code as an activity'
ActivityName = "$ManifestModule.CodeActivity"
TypeName = "$ManifestModule.WebUIs.CodeActivitySettingsPart"
IsActionActivity = $true
AssemblyName = $LoadedAssembly.Fullname
}
$Params
.\New-FIMActivityInformationConfigurationObject.ps1 @Params
}
}
END
{
}

View File

@ -0,0 +1,104 @@
<#
.SYNOPSIS
Creates Activity Information Configuration (AIC) in FIM 2010
.DESCRIPTION
TBD.
.PARAMETER Uri
The URI where the FIM 2010 Service can be reached. Default credentials are used for
access, so the user logged in must have permission to access the FIM Service Schema
.PARAMETER DisplayName
The display name of the AIC as it will appear in the FIM Portal
.PARAMETER Description
The description of the AIC
.PARAMETER ActivityName
TBD
.PARAMETER AssemblyName
TBD
.PARAMETER TypeName
TBD
.PARAMETER IsActionActivity
TBD
.PARAMETER IsAuthenticationActivity
TBD
.PARAMETER IsAuthorizationActivity
TBD
.PARAMETER IsConfigurationType
TBD
.NOTES
April 18, 2012 | Soren Granfeldt (soren@granfeldt.dk)
- initial version
.LINK
http://blog.goverco.com
#>
[CmdletBinding()]
PARAM
(
[string] $Uri = "http://localhost:5725",
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $DisplayName = "",
[string] $Description = "",
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $ActivityName = "",
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $AssemblyName = "",
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $TypeName = "",
[bool] $IsActionActivity = $false,
[bool] $IsAuthenticationActivity = $false,
[bool] $IsAuthorizationActivity = $false,
[bool] $IsConfigurationType = $true
)
BEGIN
{
$me = $MyInvocation.MyCommand -replace '\.ps1$', ''
Write-Debug "BEGIN: $Me"
Import-Module (Join-Path $PWD "FIM2010-Module.psm1") -Force
If(@(Get-PSSnapin | Where-Object {$_.Name -eq "FIMAutomation"} ).Count -eq 0) {Add-PSSnapin FIMAutomation}
}
PROCESS
{
Write-Debug "PROCESS: $me"
$ExistObject = Export-FIMConfig -Uri $Uri OnlyBaseResources -CustomConfig "/ActivityInformationConfiguration[ActivityName='$DisplayName']"
$NewObject = New-FIMImportObject -objectType "ActivityInformationConfiguration"
If(!$ExistObject) {
Set-FIMAttribute -object $NewObject -attributeName "DisplayName" -attributeValue $DisplayName
Set-FIMAttribute -object $NewObject -attributeName "Description" -attributeValue $Description
Set-FIMAttribute -object $NewObject -attributeName "ActivityName" -attributeValue $ActivityName
Set-FIMAttribute -object $NewObject -attributeName "AssemblyName" -attributeValue $AssemblyName
Set-FIMAttribute -object $NewObject -attributeName "TypeName" -attributeValue $TypeName
Set-FIMAttribute -object $NewObject -attributeName "IsActionActivity" -attributeValue $IsActionActivity
Set-FIMAttribute -object $NewObject -attributeName "IsAuthenticationActivity" -attributeValue $IsAuthenticationActivity
Set-FIMAttribute -object $NewObject -attributeName "IsAuthorizationActivity" -attributeValue $IsAuthorizationActivity
Set-FIMAttribute -object $NewObject -attributeName "IsConfigurationType" -attributeValue $IsConfigurationType
$NewObject | Import-FIMConfig -uri $Uri
Write-Debug "$($NewObject.ObjectType.ToString()) '$DisplayName' created successfully"
$CreatedObject = Export-FIMConfig -Uri $Uri OnlyBaseResources -CustomConfig "/ActivityInformationConfiguration[ActivityName='$ActivityName']"
$CreatedObject
}
else
{
Write-Warning "$($NewObject.ObjectType) '$DisplayName' already exists"
$ExistObject
}
}
END
{
Write-Debug "END: $me"
}

View File

@ -0,0 +1,32 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Granfeldt.FIM.ActivityLibrary")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Granfeldt.FIM.ActivityLibrary")]
[assembly: AssemblyCopyright("Copyright © Goverco 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using '*'.
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: ComVisible(false)]
//NOTE: When updating the namespaces in the project please add new or update existing the XmlnsDefinitionAttribute
//You can add additional attributes in order to map any additional namespaces you have in the project
//[assembly: System.Workflow.ComponentModel.Serialization.XmlnsDefinition("http://schemas.com/Granfeldt.FIM.ActivityLibrary", "Granfeldt.FIM.ActivityLibrary")]

View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Granfeldt.FIM.ActivityLibrary.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,24 @@
param
(
[switch] $IISReset
)
function get-webpageWithAuthN([string]$url,[System.Net.NetworkCredential]$cred=$null){
write-host -foregroundcolor green "Warming up $url";
$wc = new-object net.webclient;
$wc.credentials = $cred;
#$wc.Headers.Add("user-agent", "PowerShell");
$html = $wc.DownloadString($url);
#$html
}
if (Test-Path "C:\Temp\_FIM-WF-*.log") { Del "C:\Temp\_FIM-WF-*.log" }
(Join-Path $PWD Granfeldt.FIM.ActivityLibrary.dll) | .\Add-AssemblyToGlobalAssemblyCache.ps1
Get-Service FIMService | Restart-Service -Verbose
if ($IISReset) { IISRESET }
#FIM
$website = "http://localhost/IdentityManagement"
$credentials = [System.Net.CredentialCache]::DefaultCredentials;
#get-webpageWithAuthN -url $website -cred $credentials

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:mime-type</Name><Value>application/octet-stream</Value></Property></Properties></ItemProperties>

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:mime-type</Name><Value>application/octet-stream</Value></Property></Properties></ItemProperties>

View File

@ -0,0 +1,73 @@
<#
.SYNOPSIS
Installing Assemblies to Global Assembly Cache (GAC)
.DESCRIPTION
This script is an alternative to the GACUTIL available in
the .NET Framework SDK. It will put the specified assembly
in the GAC.
.EXAMPLE
.\Add-AssemblyToGlobalAssemblyCache.ps1 -AssemblyName C:\Temp\MyWorkflow.dll
This command will install the file MyWorkflow.dll from the C:\Temp directory in the GAC.
.EXAMPLE
Dir C:\MyWorkflowAssemblies | % {$_.Fullname} | .\Add-AssemblyToGlobalAssemblyCache.ps1
You can also pass the assembly filenames through the pipeline making it easy
to install several assemblies in one run. The command abobe will install
all assemblies from the directory C:\MyWorkflowAssemblies, run this command -
.PARAMETER AssemblyName
Full path of the assembly file
.NOTES
April 18, 2012 | Soren Granfeldt (soren@granfeldt.dk)
- initial version
.LINK
http://blog.goverco.com
#>
[CmdletBinding()]
PARAM
(
[Parameter(Mandatory=$true, ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]
[ValidateNotNullOrEmpty()]
[string] $AssemblyName = "",
[switch]$PassThru
)
BEGIN
{
$me = $MyInvocation.MyCommand -Replace '\.ps1$', ''
Write-Debug "BEGIN: $Me"
if ( $null -eq ([AppDomain]::CurrentDomain.GetAssemblies() |? { $_.FullName -eq "System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" }) ) {
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") | Out-Null
}
$PublishObject = New-Object System.EnterpriseServices.Internal.Publish
}
PROCESS {
Write-Debug "PROCESS: $me"
foreach ($Assembly in $AssemblyName)
{
if ( -not (Test-Path $Assembly -type Leaf) )
{
throw "The assembly '$Assembly' does not exist."
}
$LoadedAssembly = [System.Reflection.Assembly]::LoadFile($Assembly)
if ($LoadedAssembly.GetName().GetPublicKey().Length -eq 0)
{
throw "The assembly '$Assembly' must be strongly signed."
}
Write-Verbose "Installing: $Assembly"
$PublishObject.GacInstall($Assembly)
if ($PassThru) { $_ }
}
}
END
{
Write-Debug "END: $me"
}

View File

@ -0,0 +1,73 @@
# April 17, 2012 | Soren Granfeldt (soren@granfeldt.dk)
# - initial version
#----------------------------------------------------------------------------------------------------------
function Get-FIMResource
{
PARAM($Filter, $Uri = $DefaultUri)
END
{
$resources = Export-FIMConfig -CustomConfig $Filter -Uri $Uri
$resources
}
}
#----------------------------------------------------------------------------------------------------------
function Get-FIMResourceObjectID
{
PARAM($Filter, $Uri, $FilterObjectType)
END
{
$resources = Export-FIMConfig -CustomConfig $Filter -Uri $Uri
if ($FilterObjectType)
{
$resources = $resources | ? { $_.ResourceManagementObject.ObjectType -imatch $FilterObjectType}
}
[Microsoft.ResourceManagement.Automation.ObjectModel.ExportObject] $ObjectID = $resources | Select -First 1
$ObjectID.ResourceManagementObject.ObjectIdentifier
}
}
#----------------------------------------------------------------------------------------------------------
Function Set-FIMAttribute
{
Param($object, $attributeName, $attributeValue)
End
{
$importChange = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportChange
$importChange.Operation = 1
$importChange.AttributeName = $attributeName
$importChange.AttributeValue = $attributeValue
$importChange.FullyResolved = 1
$importChange.Locale = "Invariant"
If ($object.Changes -eq $null) {$object.Changes = (,$importChange)}
Else {$object.Changes += $importChange}
}
}
#----------------------------------------------------------------------------------------------------------
Function New-FIMImportObject
{
Param($objectType)
End
{
$newObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject
$newObject.ObjectType = $objectType
$newObject.SourceObjectIdentifier = [System.Guid]::NewGuid().ToString()
$newObject
}
}
#----------------------------------------------------------------------------------------------------------
Function Add-FIMMultiValue
{
Param($object, $attributeName, $attributeValue)
End
{
$importChange = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportChange
$importChange.Operation = 0
$importChange.AttributeName = $attributeName
$importChange.AttributeValue = $attributeValue
$importChange.FullyResolved = 1
$importChange.Locale = "Invariant"
If ($object.Changes -eq $null) {$object.Changes = (,$importChange)}
Else {$object.Changes += $importChange}
}
}

View File

@ -0,0 +1,39 @@
PARAM
(
[string] $AssemblyName = "Granfeldt.FIM.ActivityLibrary.dll",
[switch] $CreateCodeActivity
)
BEGIN
{
if ( $null -eq ([AppDomain]::CurrentDomain.GetAssemblies() |? { $_.FullName -eq "System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" }) ) {
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") | Out-Null
}
}
PROCESS
{
(Join-Path $PWD $AssemblyName) | .\Add-AssemblyToGlobalAssemblyCache.ps1
$LoadedAssembly = [System.Reflection.Assembly]::LoadFile( (Resolve-Path $AssemblyName).Path )
$ManifestModule = $LoadedAssembly.ManifestModule -replace '\.dll$'
if ($CreateCodeActivity)
{
$Params = @{ `
DisplayName = 'Code Activity'
Description = 'Execute C# code as an activity'
ActivityName = "$ManifestModule.CodeActivity"
TypeName = "$ManifestModule.WebUIs.CodeActivitySettingsPart"
IsActionActivity = $true
AssemblyName = $LoadedAssembly.Fullname
}
$Params
.\New-FIMActivityInformationConfigurationObject.ps1 @Params
}
}
END
{
}

View File

@ -0,0 +1,104 @@
<#
.SYNOPSIS
Creates Activity Information Configuration (AIC) in FIM 2010
.DESCRIPTION
TBD.
.PARAMETER Uri
The URI where the FIM 2010 Service can be reached. Default credentials are used for
access, so the user logged in must have permission to access the FIM Service Schema
.PARAMETER DisplayName
The display name of the AIC as it will appear in the FIM Portal
.PARAMETER Description
The description of the AIC
.PARAMETER ActivityName
TBD
.PARAMETER AssemblyName
TBD
.PARAMETER TypeName
TBD
.PARAMETER IsActionActivity
TBD
.PARAMETER IsAuthenticationActivity
TBD
.PARAMETER IsAuthorizationActivity
TBD
.PARAMETER IsConfigurationType
TBD
.NOTES
April 18, 2012 | Soren Granfeldt (soren@granfeldt.dk)
- initial version
.LINK
http://blog.goverco.com
#>
[CmdletBinding()]
PARAM
(
[string] $Uri = "http://localhost:5725",
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $DisplayName = "",
[string] $Description = "",
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $ActivityName = "",
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $AssemblyName = "",
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $TypeName = "",
[bool] $IsActionActivity = $false,
[bool] $IsAuthenticationActivity = $false,
[bool] $IsAuthorizationActivity = $false,
[bool] $IsConfigurationType = $true
)
BEGIN
{
$me = $MyInvocation.MyCommand -replace '\.ps1$', ''
Write-Debug "BEGIN: $Me"
Import-Module (Join-Path $PWD "FIM2010-Module.psm1") -Force
If(@(Get-PSSnapin | Where-Object {$_.Name -eq "FIMAutomation"} ).Count -eq 0) {Add-PSSnapin FIMAutomation}
}
PROCESS
{
Write-Debug "PROCESS: $me"
$ExistObject = Export-FIMConfig -Uri $Uri OnlyBaseResources -CustomConfig "/ActivityInformationConfiguration[ActivityName='$DisplayName']"
$NewObject = New-FIMImportObject -objectType "ActivityInformationConfiguration"
If(!$ExistObject) {
Set-FIMAttribute -object $NewObject -attributeName "DisplayName" -attributeValue $DisplayName
Set-FIMAttribute -object $NewObject -attributeName "Description" -attributeValue $Description
Set-FIMAttribute -object $NewObject -attributeName "ActivityName" -attributeValue $ActivityName
Set-FIMAttribute -object $NewObject -attributeName "AssemblyName" -attributeValue $AssemblyName
Set-FIMAttribute -object $NewObject -attributeName "TypeName" -attributeValue $TypeName
Set-FIMAttribute -object $NewObject -attributeName "IsActionActivity" -attributeValue $IsActionActivity
Set-FIMAttribute -object $NewObject -attributeName "IsAuthenticationActivity" -attributeValue $IsAuthenticationActivity
Set-FIMAttribute -object $NewObject -attributeName "IsAuthorizationActivity" -attributeValue $IsAuthorizationActivity
Set-FIMAttribute -object $NewObject -attributeName "IsConfigurationType" -attributeValue $IsConfigurationType
$NewObject | Import-FIMConfig -uri $Uri
Write-Debug "$($NewObject.ObjectType.ToString()) '$DisplayName' created successfully"
$CreatedObject = Export-FIMConfig -Uri $Uri OnlyBaseResources -CustomConfig "/ActivityInformationConfiguration[ActivityName='$ActivityName']"
$CreatedObject
}
else
{
Write-Warning "$($NewObject.ObjectType) '$DisplayName' already exists"
$ExistObject
}
}
END
{
Write-Debug "END: $me"
}

View File

@ -0,0 +1,24 @@
param
(
[switch] $IISReset
)
function get-webpageWithAuthN([string]$url,[System.Net.NetworkCredential]$cred=$null){
write-host -foregroundcolor green "Warming up $url";
$wc = new-object net.webclient;
$wc.credentials = $cred;
#$wc.Headers.Add("user-agent", "PowerShell");
$html = $wc.DownloadString($url);
#$html
}
if (Test-Path "C:\Temp\_FIM-WF-*.log") { Del "C:\Temp\_FIM-WF-*.log" }
(Join-Path $PWD Granfeldt.FIM.ActivityLibrary.dll) | .\Add-AssemblyToGlobalAssemblyCache.ps1
Get-Service FIMService | Restart-Service -Verbose
if ($IISReset) { IISRESET }
#FIM
$website = "http://localhost/IdentityManagement"
$credentials = [System.Net.CredentialCache]::DefaultCredentials;
#get-webpageWithAuthN -url $website -cred $credentials