Create Resource Activity Example

In order to create objects in FIM using a custom workflow, you must use the CreateResourceActivity activity (Microsoft.ResourceManagement.Workflow.Activities.CreateResourceActivity). As with all workflow activities, note that this will only affect objects in the FIM Portal itself.

This example is going to be a very simple example, which demonstrates how a workflow can be created using the Create Resource Activity

Step 1: Create a .NET 3.5 Workflow Activity Library Project in Visual Studio

Step 2: Add the FIM Activites to the toolbox (Choose Items->System.WorkflowComponents->etc)

Step 3: Rename your activity to CreateGroup.cs

Step 4:Add a code activity to your workflow in the designer, rename it from codeActivity1 to  InitialiseCreateGroup.

Step 5:Add a Create Resource Activity, below the . For the purposes of this exercise, we will leave it called createResourceActivity1, but you should probably name yours something better

Step 6: Double click the InitialiseCreateGroup code activity to have the designer automatically create the InitiliseCreateGroup_ExecuteCode activity

Step 7: Right click on the createResourceActivity1 activity and select “Promote Bindable Properties”

Step 8: Adjust your code to look like this:

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
// The following are specific to this project
using Microsoft.ResourceManagement.Workflow.Activities;
using Microsoft.ResourceManagement.WebServices.WSResourceManagement;
//
namespace FIMSpecialist.DemoLibrary
{
  public partial class CreateGroup : SequenceActivity
  {
    // This is the FIM Admin GUID that we need to set as the actor attribute
    // in each activity we call.
    const string FIMAdminGuid = "7fb2b853-24f0-4498-9534-4e10589723c4";
 
    // The following are the bound properties to the create resource activity object
    public static DependencyProperty createResourceActivity1_ActorId1Property = DependencyProperty.Register("createResourceActivity1_ActorId1", typeof(System.Guid), typeof(FIMSpecialist.DemoLibrary.CreateGroup));
    //
    [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
    [BrowsableAttribute(true)]
    [CategoryAttribute("Parameters")]
    public Guid createResourceActivity1_ActorId1
    {
      get
      {
        return ((System.Guid)(base.GetValue(FIMSpecialist.DemoLibrary.CreateGroup.createResourceActivity1_ActorId1Property)));
      }
      set
      {
        base.SetValue(FIMSpecialist.DemoLibrary.CreateGroup.createResourceActivity1_ActorId1Property, value);
      }
    }
 
    public static DependencyProperty createResourceActivity1_ApplyAuthorizationPolicy1Property = DependencyProperty.Register("createResourceActivity1_ApplyAuthorizationPolicy1", typeof(System.Boolean), typeof(FIMSpecialist.DemoLibrary.CreateGroup));
 
    [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
    [BrowsableAttribute(true)]
    [CategoryAttribute("Parameters")]
    public Boolean createResourceActivity1_ApplyAuthorizationPolicy1
    {
      get
      {
        return ((bool)(base.GetValue(FIMSpecialist.DemoLibrary.CreateGroup.createResourceActivity1_ApplyAuthorizationPolicy1Property)));
      }
      set
      {
        base.SetValue(FIMSpecialist.DemoLibrary.CreateGroup.createResourceActivity1_ApplyAuthorizationPolicy1Property, value);
      }
    }
 
    public static DependencyProperty createResourceActivity1_CreateParameters1Property = DependencyProperty.Register("createResourceActivity1_CreateParameters1", typeof(Microsoft.ResourceManagement.WebServices.WSResourceManagement.CreateRequestParameter[]), typeof(FIMSpecialist.DemoLibrary.CreateGroup));
 
    [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
    [BrowsableAttribute(true)]
    [CategoryAttribute("Misc")]
    public Microsoft.ResourceManagement.WebServices.WSResourceManagement.CreateRequestParameter[] createResourceActivity1_CreateParameters1
    {
      get
      {
        return ((Microsoft.ResourceManagement.WebServices.WSResourceManagement.CreateRequestParameter[])(base.GetValue(FIMSpecialist.DemoLibrary.CreateGroup.createResourceActivity1_CreateParameters1Property)));
      }
      set
      {
        base.SetValue(FIMSpecialist.DemoLibrary.CreateGroup.createResourceActivity1_CreateParameters1Property, value);
      }
    }
 
    public static DependencyProperty createResourceActivity1_CreatedResourceId1Property = DependencyProperty.Register("createResourceActivity1_CreatedResourceId1", typeof(System.Guid), typeof(FIMSpecialist.DemoLibrary.CreateGroup));
 
    [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
    [BrowsableAttribute(true)]
    [CategoryAttribute("Parameters")]
    public Guid createResourceActivity1_CreatedResourceId1
    {
      get
      {
        return ((System.Guid)(base.GetValue(FIMSpecialist.DemoLibrary.CreateGroup.createResourceActivity1_CreatedResourceId1Property)));
      }
      set
      {
        base.SetValue(FIMSpecialist.DemoLibrary.CreateGroup.createResourceActivity1_CreatedResourceId1Property, value);
      }
    }
  }
 
  public CreateGroup()
  {
    InitializeComponent();
  }
 
  private void InitiliseCreateGroup_ExecuteCode(object sender, EventArgs e)
  {
    CreateGroup_ActorId1 = new Guid(FIMAdminGuid);
    CreateGroup_CreateParameters1 = new CreateRequestParameter[3];
 
    CreateGroup_CreateParameters1[0] = new CreateRequestParameter("DisplayName", "SecurityGroup1");
    CreateGroup_CreateParameters1[1] = new CreateRequestParameter("AccountName", "svcSecGrp1");
    CreateGroup_CreateParameters1[2] = new CreateRequestParameter("Description", "A security group created by FIM!");
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

*