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

Member since: 2010

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?

#90877 Sep 19, 2014 17:34
  • Member since: 2010

    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?

    #90879 Sep 19, 2014 17:45