Today I will introduce the simplest coding element in ILM – advanced attribute flows.
Direct attribute flows can be done with no code, but they’re not all that interesting – all you can do is flow one value directly to another, or apply a constant value. To manipulate values, or to use the values of several incoming attributes, you need to write extension code.
Import or Export?
Advanced flow rules can only produce a single attribute value, but they can take multiple attributes as input. They will be either:
- Import Flow Rules where multiple CS attributes are used to produce a single metaverse attribute; or
- Export Flow Rules where multiple metaverse attributes are used to produce a single CS attribute.
If you’re doing any type of data clean-up with your flow rules it is usually best to do this as an Import, so that only the nice, clean data gets into your metaverse.
Configure the flow rule in your MA
On the Attribute Flow page, choose the input and output attributes. Don’t worry that you haven’t written the code yet, or that you may need to change the input attributes later.
Click on New. A new form pops up asking you to give the flow rule a name (you will use this name in your code).
Now I never use the default name. It is ugly, unweildy, and explicitly mentions the attributes involved – which I will no doubt need to change later. So I adopt the simple convention of “import” or “export” followed by the name of the attribute on the output end.
Create the MA Extension
If you haven’t already done so, create an extension project for this MA. If you followed the step above, ILM will have filled in a name for the extension dll on the Configure Extensions page.
On the “Run this rules extension in a seperate process” option – leave it unticked for now. You can change it later (if you need to for performance reasons), but the dll must run in the same process as the ILM server if you want to debug from Visual Studio. And if you’re just starting out with this you will want to debug.
In Identity Manager, click your MA and choose Create Extension. Use the same name as specified in your MA, as in the picture above.
Open the Project
I introduced the subject of Visual Studio in yesterday’s post, and mentioned how I like to create an ILM Solution to keep track of all my projects. So, assuming you’ve done this, add your new project into the solution now.
Otherwise just open the project on it’s own. It doesn’t have to be in a solution.
One of the nice things about these projects is that they are already configured to compile to the Extensions folder. They also have any flow rules you’ve just configured helpfully inserted for you so you’ll know where to add your code. This is why it’s a great idea to configure some rules before creating the project.
As I mentioned yesterday though, you will need to change the class name:
MapAttributesForImport/Export
Now you can start to enter your flow rule code.
- Import flows go into Sub MapAttributesForImport;
- Export flow rules go into Sub MapAttributesForExport.
The code takes the form of a simple Case statement, where the possible values are those flow rule names you set in the MA.
Â
Select Case FlowRuleName
 Case “exportInfo”
 <code>
 Case “exportDisplayName”
 <code>
End Select
And the rules themselves?
The following will get you started writing a flow rule:
- mventry refers to the metaverse object,
- csentry refers to the connector space object,
- mventry(“attribute“).IsPresent tests that attribute has a value on the metaverse object,
- csentry(“attribute“).Value sets or returns the value of attribute on the CS object.
Here’s an example of a group of export flow rules which set the Exchange mailbox quota in AD/Exchange 2003. The “MailQuota”, “WarningPercent” and “BlockMailPercent” values have previously been imported into the metaverse from a management database. Note I am using IntegerValue rather than Value in the sums.
Â
Select Case FlowRuleName
 Case "exportMDBUseDefaults"
  'Objects: Person -> User
 'Description: MDBUserDefault is FALSE if MailQuota is set, otherwise TRUE
 'Attributes: MailQuota, inExchange
  If mventry("inExchange").Value = "Yes" Then
  If mventry("MailQuota").IsPresent Then
  csentry("mDBUseDefaults").Value = False
  Else
  csentry("mDBUseDefaults").Value = True
  End If
  End IfÂ
 Case "exportMDBStorageQuota"
  'Objects: Person -> User
  'Description: Convert WarningPercent to a KB value
  'Attributes: MailQuota, WarningPercent, inExchange
 If mventry("inExchange").Value = "Yes" Then
  If mventry("MailQuota").IsPresent Then
  Dim x As Decimal = mventry("MailQuota").IntegerValue * (mventry("WarningPercent").IntegerValue / 100)
  csentry("mDBStorageQuota").IntegerValue = x.Round(x, 0)
  End If
  End IfÂ
 Case "exportMDBOverHardQuotaLimit"
  'Objects: Person -> User
  'Description: Convert BlockMailPercent to a KB value
  'Attributes: MailQuota, BlockMailPercent, inExchange
 If mventry("inExchange").Value = "Yes" Then
  If mventry("MailQuota").IsPresent Then
  Dim x As Decimal = mventry("MailQuota").IntegerValue * (mventry("BlockMailPercent").IntegerValue / 100)
  csentry("mDBOverHardQuotaLimit").IntegerValue = x.Round(x, 0)
  End If
  End If
End SelectÂ
Compile and Test
Build your project. As I said before it should compile directly into the Extensions folder, where ILM will find it.
Now you can test your new rule by running a Full Sync on the MA. More to come on debugging…
Â