Do someone know if it's possible to attach an event receiver to profile updates?
The goal would be to update an external system (such as a CRM) when a user is updating his profile.
As James said, you could create a timer job to sync profile changes with the external system. But, to detect the changes in user profile properties, I would suggest you to look into UserProfileChangeCollection
because it contains a complete log of changed user profiles.
using (SPSite site = new SPSite("http://server1"))
{
SPServiceContext serviceContext = SPServiceContext.GetContext(site.WebApplication.ServiceApplicationProxyGroup, SPSiteSubscriptionIdentifier.Default);
UserProfileManager profileConfigManager = new UserProfileManager(serviceContext);
try
{
UserProfileChangeCollection collection = profileConfigManager.GetChanges(query);
foreach (UserProfileChange change in collection)
{
Console.WriteLine(change.AccountName);
if (change is UserProfileSingleValueChange)
{
UserProfileSingleValueChange propertyChange = (UserProfileSingleValueChange)change;
Console.WriteLine(propertyChange.ProfileProperty.Name);
}
}
}
catch (UserNotFoundException)
{
}
Not really - the User Profile properties aren't stored in a list (which is where Event Receivers are registered) - they're all stored in the User Profile Database which is managed by the User Profile Service Application.
If you want to sync profile changes with an external system, you can write a Timer Job to look up the user profile properties and synchronise them with your external system. You would configure the timer job to run at an interval, and maybe use the User Profile Change Log to find out what's been changed.