I have custom claims provider which uses user profile service to get some data when resolving claims for user. I'm creating UserProfileManager this way:
private UserProfileManager UserProfileManager
{
get
{
if (_upm == null)
{
SPServiceContext serviceContext = SPServiceContext.Current;
_upm = new UserProfileManager(serviceContext);
}
return _upm;
}
}
It works when I'm using gui for user management, because SPServiceContext.Current is present. I also have a timer job which performs some operation on user permissions, so it also uses my custom claim provider. The problem is, that there is no SPServiceContext.Current in OWSTIMER process and I can't create UserProfileManager instance.
How can I obtain service context for UserProfileManager in timer job (OWSTIMER process)?