Find Material of a direct shape in linked file

I would like to be abe to find the name of the material that is set to a direct shape that is placed in a linked file.
I am having trouble implementing the directshape .GetMaterialIds() GetMaterialIds Method even without the trouble of getting into linked files and so on?
Is this even possible?

In standard components you would Right click a graphical element and set Linked Elements.

Or Query the linked files elements