Question

I should find a organization profile by it's ID (GUID). The OrganizationProfileManager has methods to return profile by it's recordId(long) and search pattern(string). I looked for a solution to use search pattern but I have not find anything.

How can I get organization by it's ID? I do not like to use recursive method to go through all organizations.

thnx

Was it helpful?

Solution

Maybe Reflectoring the OrganizationProfileManager class could give some insight into how SHarePoint itself uses that class. Using ILSpy you'll see that there is an

internal OrganizationProfile GetOrganizationProfile(Guid orgID)

method in the OrganizationProfileManager class.

Use Reflection to invoke it:

Type[] paramTypes = new Type[] { typeof(Guid) };
object[] paramInput = new object[] { orgId }; // your org id goes here

var manager = new OrganizationProfileManager(SPServiceContext.GetContext(SPcontext.Current.Site));
var methodInfo = typeof(OrganizationProfileManager).GetMethod("GetOrganizationProfile", BindingFlags.NonPublic | BindingFlags.Instance, Type.DefaultBinder, paramTypes, null);
var profile = (OrganizationProfile)methodInfo.Invoke(manager, paramInput); 
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top