I am attempting to eliminate the issue of Security Roles being dropped when changing a User's Business Unit in CRM 2011. I have taken a few approaches with varying degrees of success, but none provide a seamless solution. So far a combination of plugins seems to be the best way.
The challenge is this: The Security Roles are dropped after the pre-validation stage, but before the pre-operation stage. I am able to capture the user's security roles in the original Business Unit when I register my plugin on the pre-validation stage if I execute an update other than changing the Business Unit, but the pre-validation plugin does not get triggered when running a Change Business Unit Update (the first stage that occurs is pre-operation). I need to execute the pre-validation plugin when updating the user's Business Unit. Once I get the name of the security role, I can store it in the PluginExecutionContext shared variables, then in my post-stage event plugin, I can query for the new security role with the correct name that is associated with my new Business Unit (that part of the code is working).
Has anyone either figured out how to:
a) transfer a user's security roles from the original BU to a new one (using plugins or not)
OR
b) trigger a plugin registered on the pre-validation stage for a Change User's Business Unit action