Our monthly Virtual Happy Hour is happening this week, Fri Feb 23!

Try our conversational search powered by Generative AI!

SynchronizeUser issues "Object reference not set to an instance of an object."


I need to run SyncronizeUser in a scheduled job in order to sync all users from AD to Community, so that I can automatically join them to specific clubs based on their AD info.

EPiServer.Common.Web.Authorization.Integrator.SynchronizeUser(user, null, true);

However, this line of code issues "Object reference not set to an instance of an object." on Roles.GetRolesForUser()...

Now, the workaround that I could Google for was that Roles.Provider.GetRolesForUser() should be called instead and when I call it directly, it works (just like it doesn't work when calling Roles.GetRolesForUser()). Do I write my own Integrator? Or is there something I am doing wrong?

Sep 19, 2014 17:34

Now that I have c/p-ed the code from dotPeek and changed just Roles.GetRolesForUser to Roles.Provider.GetRolesForUser, everything works. Basically, my question is if this is the right approach?

Sep 19, 2014 17:45
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.