In addition to the green-screen technique described by jrista, you can look at the high-end masking plugins. Corel's Knockout 2 (formerly Ultimatte Knockout), for instance, did shadows rather nicely (although it's not fully compatible with recent Photoshop releases). Extracting masked elements from a scene that is similar to the target environment can also eliminate the colour casts one often gets when working with chroma-key (or, really, in any environment that is substantially different in colour from the target environment).
But let's not kid ourselves: photo compositing is hard. It's relatively easy to transpose a complete subject grouping to a new environment/background, but it's devilishly difficult to assemble individual subjects into a coherent, believable grouping. The problem with shadows and emitted light is that neither of them can be taken in isolation. Shadows fall on other objects as well as on the background, and light emitted from one object will illuminate other objects in the scene.
That means either painting some of the light and shadows manually or recreating the scene as a 3D model and extracting light and shadow maps to render onto the completed scene. (It usually takes a combination of the two to make something that passes deep scrutiny.) How much work you'll need to do depends on how complex the composition is, how big the resulting image will be, and how believable the result needs to be.