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.
11th August 2012: Just want the dll? A version compiled for FIM R2 is here with NO WARRANTY and NO SUPPORT: http://www.wapshere.com/missmiis/wp-content/uploads/2012/08/FIM.CustomWorkflowsActivityLibrary.zip. AIC config details are below in this post.
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 (note I updated the pic above and now the functions below say “AccountName Option 1” instead of just “Option 1” – but they’re doing the same thing):
Developing the Activity
|This activity is complicated compared to my powershell one, so I’ll just summarise the steps.
As well there are a bunch of code activities which smooth the way, setting up parameters and passing variables around.
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
Activity Name: FIM.CustomWorkflowsActivityLibrary.GenerateUnique
Assembly Name: FIM.CustomWorkflowsActivityLibrary, version=184.108.40.206, Culture=Neutral, PublicKeyToken=abd0a8713d768ea1
Is Action: yes
Ttype Name: FIM.CustomWorkflowsActivityLibrary.GenerateUniqueUI
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”
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.
Update for FIM R2
This activity seems to be working fine on R2.
If you are recompiling remember to first update the dlls in the “lib” folder to the versions that came with your current version of FIM.
Also I notice I don’t have a Windows SDK folder or gacutil on my new lab server. I copied gacutil.exe from somewhere else and it works fine – only it didn’t work from Build Events where I’ve put it in this solution. I had to open a command prompt “as administrator” and run gacutil from there.