I had a single server farm where the User Profile Application and Synchronization services were working fine. I was scaling out the environment for a client, and needed to relocate the UPA/UPS services to the new application server.
I proceeded to reprovision the services, and the UPA started fine. However the UPS service wouldn’t start. It wouldn’t get stuck starting, it would try for awhile then fail. A quick look at the ULS showed this error:
Exception trying to write the management agent stack size for the Moss MA. System.UnauthorizedAccessException: Access to the registry key ‘HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
MOSS-419f823a-161b-4250-9253-29b98762547d’ is denied.
at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey, RegistryKeyPermissionCheck permissionCheck, RegistrySecurity registrySecurity)
at Microsoft.Office.Server.Administration.UserProfileApplication.SetupSynchronizationService(ProfileSynchronizationServiceInstance profileSyncInstance)
This was very weird, I had logged in with the farm account that was set as a local administrator, this should have worked. I found in this forum article that I should have rebooted for the correct security tokens to be set. I had only granted administrative privileges before logging in, and once I bounced the server the UPS started fine.