Share via


MIM2016 MIMWAL: Create workflow for changing e-mail address

The goal with this guide is to describe how to do a workflow in FIM/MIM for doing the following:

  • * Change a users primary email address
  • * Take the users old primary email address and make it into an alias
  • * Schedule a removal of the abovementioned alias for some point in the future

The workflow could either be manually triggered (by some user checking some attribute in the portal for updating the user's information) or preferrably when some synchronization says a user has changed name.

In order to do this I'm using the MIMWAL update resources activity so you need to have MIMWAL installed. The screenshots are from MIMWAL 2.17.

Activity 1

First you need a step for getting the user's new address. I won't go through how to do that here since this step is very different depending on what you want to do. In my case I have a powershell script activity that talks to the Swedish Skatteverket (the government that keeps track of all peoples registered names in Sweden). The important thing for the rest of the description to work is that this step puts the new address in [//WorkflowData/MailAddress].

Activity 2

For the next step I'm assuming that you have synchronized the attribute ProxyAddresses over from you AD to the attribute ProxyAddressCollection in you MIM Service. This attribute in AD contains all mail aliases for a particular user. The primary address is prefixed with "SMTP:" (capital!) and all other addresses are prefixed with "smtp:". Make an update resources activity. By clicking "Advanced Features" you get a field for an attribute that you want to iterate over, ie the updates of the activity will be executed once for every value in that particular attribute. We want to iterate over [//Target/ProxyAddressCollection].

For every address we check two things:

1. Is this the old primary address? If so, save it in a variable for later use:

IIF(Eq(Left([Value],5),"SMTP:",true),[//Value],Null()) --> [//WorkflowData/OldPrimarySMTP]

2. Is this address equal to the new primary address that we got from step 1? If so, save also this address for later use (meaning the variable in question will simply contain the new primary address prefixed with "smtp:"):

IIF(Eq([//Value],"smtp:"+[//WorkflowData/MailAddress]),[//Value],Null()) --> [//WorkflowData/NewPrimarySMTP]

The activity now should look something like this:

Activity 3

Do another update resources activity. This step is only supposed to happen if the new primary address actually isn't the same address as the old one, so in the "Activity Execution Condition", put Not(Eq([//WorkflowData/OldPrimarySMTP],"SMTP:"+[//WorkflowData/MailAddress])).

We want to put the old primary address into a place where we later can look for it and remove it completely. The workflow for this is a separate thing that I haven't described here, but it will look in the attribute extAddressesToBeRemoved and remove all addresses found there from the object. It will do that for all object with a passed extRemoveAliasDate. So those two variables must be populated now. Also in this activity we'll fix the ProxyAddressCollection and Email attributes with the correct new values.

Now for the updates of this activity, enter the following:

1. Put the old primary address into extAdressesToBeRemoved

InsertValues([//Target/Email]) --> [//Target/extAddressesToBeRemoved]

2. Put a date a year from now into extRemoveAliasDate

DateTimeAdd(DateTimeNow(),"365.00:00:00.0") --> [//Target/extRemoveAliasDate]

3. Put the new address in the Email attribute

[//WorkflowData/MailAddress] --> [//Target/Email]

4. Remove the value containing the old primary address from ProxyAddressCollection

RemoveValues([//WorkflowData/OldPrimarySMTP]) --> [//Target/ProxyAddressCollection]

5. Remove the value containing the new primary address from ProxyAddressCollection (if it earlier existed as a mere alias, ie prefixed with "smtp:")

RemoveValues([//WorkflowData/NewPrimarySMTP]) --> [//Target/ProxyAddressCollection]

6. Put the old primary address back into ProxyAddressCollection, this time prefixed with small letters "smtp:"

InsertValues(ReplaceString([//WorkflowData/OldPrimarySMTP],"SMTP:","smtp:")) --> [//Target/ProxyAddressCollection]

7. Put the new primary address into ProxyAddressCollection

InsertValues("SMTP:"+[//WorkflowData/MailAddress]) --> [//Target/ProxyAddressCollection]

The activity should now look something like this:

After this is might be a good idea with an additional activity to send a notification to the user about the changed address. Just make sure you're sending the notification to a working address. The new primary address probably won't work yet since it hasn't synchronized over to AD/Exchange!