On many services - gambling and others - every user gets unique payment address.
According to this doc -
https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list i can do it with
getnewaddress.
Also i can get total amount -
getbalance.
And this command -
sendfrom [minconf=1] [comment] [comment-to]
What is withdrawal logic ? It takes money from random addressess if only total amount allows to do its operation?