While implementing dynamic dimension data security in Analysis Services 2005 I ran into a problem with linking members of a set into another hierarchy. My problem was that I needed a set of members from a specific hierarchy "A" to specify the allowed member set of the dimension hierarchy "A". Unfortunately it wasn't possible to get the members from the hierarchy "A". It was only possible to get them from another hierarchy "B" of the same dimension.
As you possibly know, there is a nice MDX function LinkMember, which can be used to do exactly this kind of conversion between hierarchies. Sadly, you can only link one member, but not a whole set of members.
I've searched a long time to find a solution for this problem, but couldn't find something. As far as I know, there is no possibility to do this in MDX, so I wrote my own LinkSet function in a .NET assembly. The following code-listing shows how I did that. I know there is possibly a better and more flexible solution, but it works for my requirements ...