Skip to content

Generate Unique Attribute Activity

When I first started out with MIIS I found the coding heavy going – but soon realised that the same few extension-writing methods are used for pretty much everything, and the fun bit was just how much I could achieve with them!

Now on to FIM and I have struggled every bit as much with learning how to write workflow activities, not particularly helped by the official documentation which I can only assume is computer generated, it is so completely unhelpful. But after a recent obsessive spate I’m finally starting to get the hang of it, and this has brought me to the next fantasy activity on my list – something to generate a unique attribute, such as an AccountName.

10th May 2011: I have just uploaded a new version of the activity. It has some more error checking and extra options for character-replacement and regular expression pattern matching. You will find the Download link further down this page.

The idea

What I want is a way to generate an attibute based on a series of rules. If I don’t get a unique value with the first (ideal) rule, then I move to the second, then the third, then if completely desperate the fourth… Hopefully I’d have found something good by then.

In an effort to reduce effort (if you can have that) this activity relies on the OOB Function activity to generate the possible strings in order of preference. So here’s what the workflow looks like configured with three possible choices:

And here is one of the Function activties, which generates a string and puts it in a WorkflowData parameter:

Developing the Activity

This activity is complicated compared to my powershell one, so I’ll just summarise the steps.

  1. A CurrentRequestActivity grabs the workflow details from FIM,
  2. A ReadTargetActivity gets the details of the object we’re trying to modify,
  3. A WHILE loop goes through the possible options until a unique value is found (or we run out of options),
  4. Within the WHILE loop, the EnumerateResourcesActivity does the actual looking up of the proposed attribute value, to see if it’s already taken,
  5. We then have an IfElse statement to handle the lookup results:
    • If we found a good match we write it to the target resource using an UpdateResourceActivity,
    • If we didn’t find a match an error is thrown – this leads to a PostProcessingError in FIM. Of course you could do something else like send an email here.

As well there are a bunch of code activities which smooth the way, setting up parameters and passing variables around.

The Code

Here is the most recent copy of the solution. You will have to compile it yourself. Make sure you understand what it is doing and adapt the code for your own purposes.

Offered as an example only with NO WARRANTY and NO SUPPORT: Download Code

AIC Configuration

Activity Name: FIM.CustomWorkflowsActivityLibrary.GenerateUnique
Assembly Name: FIM.CustomWorkflowsActivityLibrary, version=1.0.0.0, Culture=Neutral, PublicKeyToken=abd0a8713d768ea1
Is Action: yes
Ttype Name: FIM.CustomWorkflowsActivityLibrary.GenerateUniqueUI

Logging

This activity logs to the Application Event Log, but only if you first register the source liek this:

new-eventlog -LogName “Application” -Source “FIM Custom Workflow”

Other Reading

If, like me, you’re doing this WWF development stuff for the first time, I did find this short tutorial very helpful. Despite my rubbishing the MSDN FIM documentation above, there is lots of good stuff there too, of course.

{ 6 } Comments

  1. Brian Desmond | September 5, 2010 at 8:25 am | Permalink

    Carol-

    A ResolveGrammarActivity will convert those [//WorkflowData/] values (as well as //Target and //Requestor) in to actual values. Assign the XPath expression to GrammarExpression and you can get the output from ResolvedExpression.

  2. Carol | September 5, 2010 at 8:45 am | Permalink

    Hi Brian,

    yes everyone seems very keen on this ResolveGrammarActivity, but while the official documentation says “for internal FIM use only” and “not supported” I will be avoiding it. I think it would only have saved me a few lines of code anyway.

  3. Layan Thadani | August 29, 2011 at 11:51 am | Permalink

    How do I install this activity please help. I am new to fim 2010

  4. Carol | August 30, 2011 at 1:25 am | Permalink

    I suggest you work through the example on MSDN – see http://msdn.microsoft.com/en-us/library/ff859524.aspx

  5. Layan Thadani | September 6, 2011 at 3:26 am | Permalink

    I followed the example I entered the following values in the FIM Portal

    Activity Name: FIM.CustomWorkflowsActivityLibrary.GenerateUnique

    Assembly Name: GenerateUnique, version=1.0.0.0, Culture=Neutral, PublicKeyToken=abd0a8713d768ea1

    Type Name: FIM.CustomWorkflowsActivityLibrary.WebUIs.GenerateUniqueUI

    but the Activity is not showing up in the FIM Portal

  6. Carol | September 6, 2011 at 4:02 am | Permalink

    Did you iisreset? If so, and it’s still not there, double check your actual class names by using the Object Browser in Visual Studio.

Post a Comment

Your email is never published nor shared. Required fields are marked *
*