Is there anyway to match a sun lamp to the direction of the sun in an environment map?
If the sun is clearly visible in the HDR, you can put a camera at scene origin, look around in rendered viewport mode and locate it.

If the sun is hard to locate precisely, you need to put a sun clock into the scene: put a vertical pole into the scene and measure the angle and distance of the shadow. Then you know where the sun is and how best to match the shadow.



It will work for sunny HDRs with clear shadows the best. Also to get accurate shadows from HDR use environment setup like this.



For diffused shadow HDRs you will have to guess where the center of shadow is and how long it is, and substitude sun lamp for a point/spot lamp with some size. You can get the distance-size ratio from how the penumbra of the shadow looks: