I need a WebPart similar to Colleagues WebPart, but to return which users have added me as a Colleague.
Does it already exist? Or, how can I develop it? I'm using SharePoint 2010.
I've put some thought into this request before, and again today when I read your post here. The problem is that the API does not support this type of lookup. Its unfortunate, and a glaring gap in the current product.
As John Chapman mentioned, if you were to iterate through every profile in the system it is likely to take awhile and will not scale well. For processes like this, or to handle things like "this week's birthdays" and other social listings, the best way to handle it seems to be to write a scheduled process that can prep the data so that it is available when needed. Specifically I would write a timer job that calls a web service to initiate the processing and have it write the data out either to a back end database or to a SharePoint list.
The time it would take to process will vary based on the number of users in the system and how many connections everyone establishes. If it is something that needs to be updated daily it shouldn't be a big deal, but hourly may not be a good idea in larger environments.
I have been working on a similar type of web part. In going through the SharePoint object model for user profiles, the only function that exists for determining the colleague relationship is on a one-by-one using the IsColleague function of the ColleageManager: http://msdn.microsoft.com/en-us/library/ms491859.aspx
What this means is in order to find out who has you listed as a colleague, you would have to do a for-each statement on every profile to see if you are listed as their colleague. In my situation, I had 2400 profiles and it took 20+ seconds to run that function. Not very efficient for loading the information into a web part.
The alternative work-around, though not a recommended way of doing things, is to query the Profile database directly in SQL. You could do a join query that pulls the UserProfile RecordID that matches your NT login, then join the colleagues table matching the RecordID, and then join the UserProfile table for all usernames that match the RecordIds from the colleagues table.