When is the following a formula for local cohomology?

Suppose $$R$$ is a Noetherian local ring, and $$\kappa$$ its residue field. For $$R$$ module $$M$$, we can consider the module $$N:=\kappa \otimes_S RHom(\kappa,M)$$ where $$S$$ is the derived ring of endomorphisms of $$\kappa$$, namely $$RHom(\kappa,\kappa)$$. There is a natural map from $$N$$ to $$M$$, under what conditions is $$N$$ the local cohomology of $$M$$? I'm fairly sure it's true when $$R$$ is regular (I think i have a proof) but i suspect it holds much more generally. Note the tensor product is of course also derived.