none
Custom workflow activity RRS feed

  • Question

  • Can anybody please give me heads up in developing a custom workflow activity that would add certain number number of days in expiration time. Waiting for a helpful and quick response.
    Friday, March 22, 2013 7:55 PM

Answers

  • Actually... I am half right.

    You changed the value of the FIMAdminGuid constant. While you can do that, by convention most people use 7fb2b853-24f0-4498-9534-4e10589723c4, which is the "well-known FIM Administrator GUID"

    If you change it, I believe it will still work, but you need to ensure the account you change it to has all the necessary rights ... and honestly, it's just easier to use the FIM Admin guid.

    The rest of your workflow looks pretty good - I'd say you've picked this up pretty well. Fix that one GUID issue and it should work for you.

    - Ross Currie


    FIMSpecialist.com | MCTS: FIM 2010 | Now Offering ECMA1->ECMA2 Upgrade Services


    • Proposed as answer by Ross Currie Monday, March 25, 2013 2:21 PM
    • Edited by Ross Currie Monday, March 25, 2013 2:21 PM
    • Marked as answer by Shobhitvaish Monday, March 25, 2013 3:43 PM
    Monday, March 25, 2013 2:21 PM

All replies

  • You'll need to setup a couple things - a ReadResourceActivity to read in ExpirationTime and then an UpdateResourceActivity to do the update. You can use the code below in a CodeActivity to setup that update:

    
    private void codeSetupUpdateResource_ExecuteCode(object sender, EventArgs e)
    {
        // FIM will bail without the .ToUniversalTime() call
        // ref http://social.technet.microsoft.com/Forums/en-US/ilm2/thread/2a131cd4-e483-4d0a-9f7b-e1042f48fc93
        updateResourceActivity.UpdateParameters = new UpdateRequestParameter[] { new UpdateRequestParameter("ExpirationTime", UpdateMode.Modify, ExpirationTime.AddDays(5).ToUniversalTime()) };
    }


    My Book - Active Directory, 4th Edition
    My Blog - www.briandesmond.com

    • Proposed as answer by Ross Currie Monday, March 25, 2013 3:12 AM
    Friday, March 22, 2013 11:10 PM
    Moderator
  • Thanks Brian, Can you please provide the steps starting from desgin and then code. Actually I am very new to custom workflow desgin
    Saturday, March 23, 2013 2:10 AM
  • I want to add some x no of days to expiration time.

    Can some one please list down steps including activities and code. I am new to desgining custom workflow activity

    Saturday, March 23, 2013 7:39 AM
  • Are you familiar with PowerShell? The PowerShell Workflow Activity might be helpful: http://fimpowershellwf.codeplex.com/

    There is information on how to use it in the Documentation tab.

    Saturday, March 23, 2013 2:52 PM
  • There is a getting started guide (and a bunch of additional content) available on MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ff859524(v=vs.100).aspx 

    My Book - Active Directory, 4th Edition
    My Blog - www.briandesmond.com

    Saturday, March 23, 2013 3:20 PM
    Moderator
  • You could maybe take a look at the Code Run activity in my library. If you're unable to use the current activties, the source code may serve as a good starting point.

    https://fimactivitylibrary.codeplex.com/

    Regards, Soren Granfeldt
    blog is at http://blog.goverco.com | facebook https://www.facebook.com/TheIdentityManagementExplorer | twitter at https://twitter.com/#!/MrGranfeldt

    Saturday, March 23, 2013 3:49 PM
  • You seemed to find my website okay, did you find your way to my Update Resource Activity Example article?

    I cover pretty much everything from creating the Visual Studio project, including full source code.

    Once you read through that example, all you would need to do is to include the code Brian included above:

    private void codeSetupUpdateResource_ExecuteCode(object sender, EventArgs e)
    {
        // FIM will bail without the .ToUniversalTime() call
        // ref http://social.technet.microsoft.com/Forums/en-US/ilm2/thread/2a131cd4-e483-4d0a-9f7b-e1042f48fc93
        updateResourceActivity.UpdateParameters = new UpdateRequestParameter[] { new UpdateRequestParameter("ExpirationTime", UpdateMode.Modify, ExpirationTime.AddDays(5).ToUniversalTime()) };
    }

    where I have

    // Add the AccountName and DisplayName we generated as parmaters to update on the object
    updateRequestParameters.Add(new UpdateRequestParameter("AccountName", UpdateMode.Insert, accountName));
    updateRequestParameters.Add(new UpdateRequestParameter("DisplayName", UpdateMode.Insert, accountName));            
     

    If you get stuck on any particular step, let us know.

    - Ross Currie


    FIMSpecialist.com | MCTS: FIM 2010 | Now Offering ECMA1->ECMA2 Upgrade Services

    • Proposed as answer by Ross Currie Monday, March 25, 2013 3:12 AM
    Monday, March 25, 2013 3:11 AM
  • Yeah Ross. I went through updateresourceactivity, it was very helpful and I was able to make my custom activity. I integrated it into FIM but it dint seems to be working and then I debuged it. I got to know that readresource activity is not working however codeactivity is able to read the target resource  ID. Could you please let me know that why read resource activity is not working. My code is same as yours update resource activity but it is not just able to read the resource.
    Monday, March 25, 2013 7:26 AM
  • What does your MPR/Set/Workflow configuration look like?

    Perhaps you could post some of the source code for how you assign values to the properties on your ReadResource object?

    - Ross Currie


    FIMSpecialist.com | MCTS: FIM 2010 | Now Offering ECMA1->ECMA2 Upgrade Services

    Monday, March 25, 2013 7:38 AM
  • For testing I have created a temporal set(ExpiringGroups) which would have groups which are having expiration date after 30 days from today. A test action workflow to add the custom activity. And then finally a set transition MPR which would trigger this workflow on transition into ExpiringGroups. Everything  is working fine ad custom activity is getting called(Got to know while debugging)

    Here is the code:-

    using System;
    
    using System.ComponentModel;
    
    using System.ComponentModel.Design;
    
    using System.Collections;
    
    using System.Linq;
    
    using Microsoft.ResourceManagement.WebServices.WSResourceManagement;
    
    using Microsoft.ResourceManagement.Workflow.Activities;
    
    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;
    
    namespace UpdateExpirationTime
    
    {
    
    public partial class UpdateExpirationTimeActivity : SequenceActivity
    
    {
    
    const string FIMAdminGUID = "f55b20e2-eef3-4139-a34b-f9c2f9a806f2";
    
    public UpdateExpirationTimeActivity()
    
    {
    
    InitializeComponent();
    
    }
    
    private void InitializeReadUser_ExecuteCode(object sender, EventArgs e)
    
    {
    
    ReadUser.ActorId = new Guid(FIMAdminGUID);
    
    ReadUser.ResourceId = currentRequest.CurrentRequest.Target.GetGuid();
    
    ReadUser.SelectionAttributes = new string[] { "ExpirationTime" };
    
    }
    
    private void InitializeUpdateResource_ExecuteCode(object sender, EventArgs e)
    
    {
    
    if (ReadUser.Resource != null)
    
    {
    
    ResourceType user = ReadUser.Resource;
    
    DateTime expirationTime = (DateTime)user["ExpirationTime"];
    
    UpdateResource.ActorId = new Guid(FIMAdminGUID);
    
    UpdateResource.ResourceId = currentRequest.CurrentRequest.Target.GetGuid();
    
    UpdateResource.UpdateParameters = new UpdateRequestParameter[] { new UpdateRequestParameter("ExpirationTime", UpdateMode.Modify, expirationTime.AddDays(90).ToUniversalTime()) };
    
    }
    
    }
    
     
    
    }
    
    }



    Here is the design :-

    Its coming to readuser activity during debugging and then it just coming out without reading. Kindly help.

    Thanks,

    Shobhit vaish


    Monday, March 25, 2013 8:37 AM
  • Ross could you please help. I am eagerly waiting for your helpful reply.
    Monday, March 25, 2013 10:24 AM
  • My guess is that it's having troubles reading the ExpirationTime attribute.

    I assume you have a breakpoint at this line

    if (ReadUser.Resource != null)


    and that the breakpoint is never being hit.

    Try removing this line and see if your break point gets hit:

    ReadUser.SelectionAttributes = new string[] { "ExpirationTime" };

    If it does, it's probably something to do with this.


    FIMSpecialist.com | MCTS: FIM 2010 | Now Offering ECMA1->ECMA2 Upgrade Services

    Monday, March 25, 2013 2:18 PM
  • Actually... I am half right.

    You changed the value of the FIMAdminGuid constant. While you can do that, by convention most people use 7fb2b853-24f0-4498-9534-4e10589723c4, which is the "well-known FIM Administrator GUID"

    If you change it, I believe it will still work, but you need to ensure the account you change it to has all the necessary rights ... and honestly, it's just easier to use the FIM Admin guid.

    The rest of your workflow looks pretty good - I'd say you've picked this up pretty well. Fix that one GUID issue and it should work for you.

    - Ross Currie


    FIMSpecialist.com | MCTS: FIM 2010 | Now Offering ECMA1->ECMA2 Upgrade Services


    • Proposed as answer by Ross Currie Monday, March 25, 2013 2:21 PM
    • Edited by Ross Currie Monday, March 25, 2013 2:21 PM
    • Marked as answer by Shobhitvaish Monday, March 25, 2013 3:43 PM
    Monday, March 25, 2013 2:21 PM
  • Hey Ross. Thanks a ton. Its working perfectly. Just changed the GUID. Thanks again man. It took 2 days to get the solution.
    Monday, March 25, 2013 3:43 PM