15 October 2010

How To Map The SharePoint 2010 'PictureURL' User Profile Property to a BDC Attribute Using Forefront Identity Manager 2010

[ UPDATE 08-Jun-11: I first used the below approach against SPS 2010 RTM and it worked fine on 3 different environments. I subsequently tried to set this up on another environment that was running version 14.0.5128.5000​ and this failed. The SPS_MV_String_PictureURL value was getting populated but the value was not mapping through to PicureURL property. This may or may not have been due to the fact that this particular instance was also configured to export those pictures to Active Directory (I never had time to get to the bottom of it - but that UPS also had another bunch of issues which led to us recreating the UPS, so the PictureURL sync failure may have been specific to that environment). In any case, if you are not using RTM (which I assume is most of you) then I can't guarantee this will work. There's a comment below from Johann who says this approach worked perfectly for him, so I'll check which version he is running and report back soon. ]

A bit of a problem...

My company store and manage all staff images in an intranet application and those images are available via the url http://company/images/XXXXXX.jpg where XXXXXX is a 6 digit number. That intranet application surfaces a web service method that returns a string called imageURL for a given staff ID.

In SharePoint (MOSS) 2007 I was able to map the PictureURL User Profile property to the imageURL property of my BDC connection. However, in SharePoint 2010 you are unable to map the property.

A bit of investigation...

They said it couldn't and/or shouldn't be done, that you could not map the URL string value from a BDC connection (or any other data connection such as an AD attribute) because the PictureURL property has a data type of PropertyDataType.URL (add reference). Now, that is half right I suppose, in that you cannot do so through the web interface; the BDC image URL string property that I want to map simply doesn't appear in the attributes drop down list in the Add New Mapping section, but....

After plenty of fruitless Googling I came to the familiar conclusion that I'm just going to have to find my own way to squirt my company's staff image URLs into the PictureURL property.

A couple of blogs suggested using FIM to map the extensionAttributeX (http://goodbadtechnology.blogspot.com/2010/05/setting-up-pictureurl-user-profile.html) so I took that a step further and did some investigations. I wanted to see what happened when you try to map a different User Profile property, which also has a URL data type, to my BDC property. So as a test I mapped the Outlook Web Access URL property, real name SPS-OWAUrl, to my BDC property (which I was able to do just fine through the web interface) and, using FIM, saw that my BDC property (imageURL) is mapped to a metaverse attribute called SP_MV_String_SPS-OWAUrl, which in turn is mapped to the real User Profile property SPS-OWAUrl.

So, using the same approach via FIM I manually created the metaverse attribute for PictureURL using the same naming convention, SP_MV_String_PictureURL, and set up the mappings in the same way. To my amazement a full crawl later voila! All my users had their corporate photo in SharePoint. Here's exactly what I did...

A resolution...

1) Open the FIM console: C:\Program Files\Microsoft Office Servers\14.0\Synchronization Service\UIShell\miisclient.exe

2) Click the Metaverse Designer button at the top

3) Select “person” in the Object Types list

4) Click Add Attribute on the right

5) In the dialog box that appears click the New Attribute button

6) Enter “SPS_MV_String_PictureURL” into the Attribute Name field, leave the other fields as they are then click OK

7) Click OK again

8) Click on the Management Agents button at the top. You should all agents listed, in my there were 4:

   a) ILMMA: the FIM service mgmt agent

   b) MOSSAD_Global: the Active Directory Domain Services agent

   c) MOSSBDC-People Image BDC: my corporate BDC connection

   d) MOSS-[someGUID]: the SharePoint Extensible Connectivity agent


9) Double click the MOSS-[someGUID] management agent

10) The properties dialog box will open, select Configure Attributes on the left menu bar

11) This will list all attributes in the user profile store. Check the list for an attribute called “PictureURL”. If it does not exist then:

   a) click the New button

   b) Enter “PictureURL” (case-sensitive) in the Name field, leave other fields as they are and click OK

12) Check that the PictureURL attribute now appears in the attribute list

13) Now select Define Object Types on the left menu bar

14) Select “user” in the Object Types list in the middle. The attributes for “user” should appear in the right pane

15) Click the Edit button:

16) Select our new attribute called PictureURL from the Available Attributes list on the left

17) Now click the lower Add button to add the attribute to the 'May have attributes' list on the right

18) Check the PictureURL attribute appears correctly on the right:

19) Click OK

20) Select Configure Attribute Flow from the left menu bar

21) From the Data Source Attribute list on the left select PictureURL

22) From the Metaverse attribute list on the right select “SPS_MV_String_PictureURL

23) Click the New button to add this new attribute flow. NOTE: do not simply click OK here as it will not add the attribute flow we just selected, you must click New to confirm it

24) Check that the attribute flow was added correctly by expanding the “Object Type: user” section at the top of the dialog box. You will have to scroll down to see the mapping we just created

25) Now click OK to close the Properties dialog box

26) Now double click the management agent called “MOSSBDC-Profile_Image_BDC” (or whatever you BDC connection agent is called) to open the properties dialog box

27) Select Configure Attribute Flow from the left menu bar

28) From the Data Source Attribute list on the left select “ImageURL” (or whatever your BDC attribute is called)

29) From the Metaverse attribute list on the right select “SPS_MV_String_PictureURL

30) Click the New button to add this new attribute flow. NOTE: again, do not simply click OK here as it will not add the attribute flow we just selected, you must click New to confirm it.

31) Finally, check that the attribute flow was added correctly by expanding the “Object Type: PeopleImageEntity” (or whatever your BDC entity class is called) section at the top of the dialog box

32) Click OK to close the properties dialog box

33) Now run a full crawl from the User Profile Service in Central Admin

That’s it!

Good Luck!

11 comments:

  1. I created and External Content Type. I can see it in Sharepoint to create external data lists, but I don't see a Management Agent for it. What do I need to do to create that BDC Management Agent?

    ReplyDelete
  2. You need to create a synchronisation connection for your BDC application from the User Profile Service page in central admin. That tells the UPS to crawl your BDC connection during incremental/full synchs. You'll need to map one of the unique UP properties to the appropriate unique property of your BDC connection e.g. (User Profile)accountName = (BDC)loginName, which basically says for every user in the UPS call the SpecificFinder method (ReadItem) in the external content type and pass in the user's account name. After that you should see the BDC MA appear in FIM.
    Note: I'll be posting a different approach to setting the PictureURL via the BDC shortly. The above approach worked well with SP2010 RTM but not so for later versions. New approach uses the object model rather than FIM modifications.

    ReplyDelete
    Replies
    1. After following above steps the attribute value for the BCS field is blank, Could you give me the url of setting the PictureURL via the BDC as you were saying in the earlier post that your would post it shortly.

      Delete
    2. setting the PictureURL via the BDC using object model

      Delete
  3. Wow! I'd be really interested in seeing you Object Model solution. Which API's are you using?

    On the above though, I'm using RTM and I'm getting and Import errorn on the BDC Management Agent that I've created. The error is "stopped-extension-dll-exception" and it happens on the DS_FULLIMPORT_MyGuid profile name. Any ideas?

    ReplyDelete
  4. That FIM error possibly relates to an uncaught exception in your BDC solution assembly. Check the Windows event logs to see if anything showed up there around the same time as the failure, I would expect to see an error referring to the assembly that threw the error along with a stack trace. Does the error occur immediately, as soon as it starts to run the ds_fullimport profile or does it run happily for a while before hitting the error? Might be worth adding some debug logging into your BDC solution then at least you can see if it is something in your code causing the problem. Can you use your BDC external content type successfully with a BDC data item web part? Also, check the ULS logs (you might want to temporarily up the diagnostic logging level for the "UPS Sync" category to verbose to get a better idea of what is failing).

    ReplyDelete
  5. This is a great and very detailed article and the solution worked for me. Thanks for sharing this!

    ReplyDelete
  6. Hi Johann, glad it worked for you. Can you please confirm the build number of your SP 2010 environment? cheers

    ReplyDelete
  7. I'm running SP2010 with SP1+June CU, and it doesn't seem to work.

    Before applying the June CU it worked, then we used PictureURL to export to thumbnailPhoto in AD. After June CU this didn't work anymore so we had to switch back to your approach again - and then it didn't work anymore.

    We can synchonize the URL from AD to any other custom User Property of type string using your approach, but it is not possible to map it to PictureURL. It has to do with the type of PictureUrl.
    I've read somewhere that instead of using a "direct" mapping on could use an "Advanced" mapping type. I havn't got that to work yet though.

    ReplyDelete
  8. I see picture URL is imported, but the pictures did get populated.

    ReplyDelete
  9. Any idea how to setup updates from multiple sources and set precedence... if BDC is not available use AD... trying to set this up, but I can't find a way to create an user profile that syncs properly, it either erases everithing that comes from BDC is there is no connection or it does not update anything that comes from BDC (and there is a connection).

    ReplyDelete