First you need to make an sql query to look up the device name (the extension number is in the table numplan, the device name in the device table and the two are linked by the help of the devicenumplanmap table).
Knowing the device name you can then make an axl serviceability request to the risport and execute the SelectCmDevices command (assuming you are on CCM5 and above) to get the IP address of the phone.
For ccm4, there's the devicelistx report where you can get the IP address from.
The following page will list axl + serviceability developer guides for all kinds of ccm versions, along with the database schema so you can formulate the query: http://www.cisco.com/en/US/products/sw/voicesw/ps556/products_programming_reference_guides_list.html
If you're on ccm5 or higher, you can also download the axlsqltoolkit from the plugins section in ccmadmin to get a working sample on how to make sql queries against the ccm.
P.S. I really think indicating the ccm version in your first question would be more than appropriate. You don't call a garage and tell them your car is broken without telling them what car it is either, do you?