5704 Views // 0 Comments // Not Rated

The Hybrid Profiler - Picture Support

I've added a new control to the Hybrid Profiler that supports pictures for SQL users. What it does is gets the images from a Picture Library, and loads them into a drop down for selection when the profile page is in "Edit" mode. There's also a thumbnail next to the drop down to make the user experience a little richer.

In addition, when you save changes to your profile, UserInfo.aspx will attempt to sync your properties with the WSS profile created for your SPUser object. More specifically, it calls into the hidden WSS user information list, gets the list item for the current user, and attempts to update each WSS user profile property (i.e., each field in this list) with the the matching value from each property of the Hybrid Profiler.

Here's what that code looks like:

Code Listing 1

  1. private void UpdateWSSPrfofile(string loginName)
  2. {
  3. //initialization
  4. int userID = SPContext.Current.Web.CurrentUser.ID;
  5. //impersonation
  6. SPSecurity.RunWithElevatedPrivileges(delegate()
  7. {
  8. //open site
  9. using (SPSite site = new SPSite(SPContext.Current.Site.Url))
  10. {
  11. //open web
  12. site.AllowUnsafeUpdates = true;
  13. using (SPWeb web = site.RootWeb)
  14. {
  15. //update wss profile
  16. web.AllowUnsafeUpdates = true;
  17. SPListItem userItem = web.SiteUserInfoList.GetItemById(userID);
  18. foreach (SettingsPropertyValue prop in ProfileHelpers.GetPropertyValuesForUser(loginName))
  19. {
  20. try
  21. {
  22. //attempt to update each property one at a time
  23. userItem[prop.Name] = prop.PropertyValue;
  24. userItem.Update();
  25. }
  26. catch { }
  27. }
  28. }
  29. }
  30. });
  31. }

Finally, I've added a new attribute to Hybrid Profiler properties: ServiceURL. What this does is allow you to specify a string (for example, "~/_layouts/HybridProfiler/PictureControl.asmx") so that you can wire up an AJAX web service to your control. This will enable asynchronous JSON calls into managed code, effectively giving your control the concept of "code behind" while still allowing it to dynamically integrate into the Hybrid Profiler infrastructure.

This is all part of a round of updates I've made to the Hybrid Provider 2.0.

The code has been uploaded to my CodePlex project site, under the latest release. The easiest upgrade path is to download the latest installer, and use it to uninstall then reinstall the Hybrid Provider. This will activate the new feature receiver code, which provisions a Picture Library to store the pictures, adds the proper controls to the UserInfo.aspx page, and updates all the configuration stuff automatically.

Have fun!

7 Tags

No Files

No Thoughts

Your Thoughts?

You need to login with Twitter to share a Thought on this post.