Troubleshooting and Triggering a Profile Import from BDC

Recently we came across a situation that was rather strange: a fairly simple BDC application definition had been created. It appeared to be configured correctly because we created a search content source for it and were able to index the contents and search through and find results afterwards. We also had an import connection in the User Profiles system configured for it, but the BDC and Membership import status always said "Idle", and the data was never imported. So what, we wondered, was it that scheduled that profile import to run, and how could we force it to occur? With some digging around, we came up with some answers.

There is a Shared Service timer job called the DLImportJob, which runs every 5 minutes. You won't see it listed in the Timer Job Definitions page in Central Admin because it's actually part of a larger timer job called the Shared Services Timer Job. The DLImportJob checks to determine if an import is needed from the BDC, and the conditions under which it will run are:

  • The profile import portion must not have been stopped/cancelled
  • The profile import portion must be complete

So, how do we troubleshoot when it doesn't run? Here are some things to check:

  • What does the main User Profiles page say for status? If it never leaves "Idle" then there is some other issue.
  • Windows event viewer messages?
  • Is search running properly and are crawls working?
  • Are normal profile imports working?
  • Are there errors in the ULS logs? An error that contains information about DLImportJob is going to be highly relevant.
  • Is the Shared Services Timer Job running and completing successfully?

If you go through all of those steps and you are still not able to resolve the underlying issue, you can programmatically force the BDC import to run. Using an instance of the UserProfileConfigManager class, you can call its StartDLImport method to try and force the import to run. Make sure you wrap this call in a try…catch block – if there are problems that are preventing your import from running successfully, they should trigger an exception and should allow you to gain a better understanding of the issue. Here's a brief code snippet that outlines the use of this API:

using Microsoft.SharePoint;

using Microsoft.Office.Server;

using Microsoft.Office.Server.UserProfiles;

//create a site so we can get context

using (SPSite theSite = new SPSite("https://someSiteCollection"))

{

//get context from the site

ServerContext sc = ServerContext.GetContext(theSite);

//get the manager

cm = new UserProfileConfigManager(sc);

//start the import

cm.StartDLImport();

}

Hope this helps you get pointed in the right direction the next time you have a problem getting your BDC data imported into the User Profile system.