0

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

1 Answer 1

1

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); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.