The quote below is taken from my answer to How to implement a game like SatoshiDice? What you are looking for is addressed in this portion of my answer below.
Get the customer amount and payment address
bitcoind getrawtransaction [The incoming transaction ID] 1. The 1 at the end will return the data in "verbose mode", which
essentially the raw data in JSON format.
From the raw transaction details, take the
vout from the
vin object. With this transaction, again call
getrawtransaction on the
From these raw transaction details find the
vout object, referenced by the
vout index from step #2. Within this
object, there should be a list of payment recipient addresses. Take
and store the first address.
It is worth mentioning that a received payment can be a summation of numerous, former transactions to multiple recipient addresses. Getting an originators address isn't always straight-forward because the original payment could consist of multiple payments, from multiple sending addresses.
This is why that in my response to the SatoshiDice question I mention taking the first address from the second
You can safely assume that if someone sends you a payment originating from multiple accounts, they control all accounts. Ergo, picking the first in the list will give you correct address.