This process is handled by CME or UCM automatically assuming you have configured them properly. Which product are you using and what errors are you encountering?
If you are asking how to get the phone to boot to third-party environments you are on the wrong forums. Try http://www.voip-info.org/wiki/view/Setup+SiP+on+7940+-+7960 Note that the 7941 does not (only 7940/7960) have an RFC-compliant SIP image. The firmware has Cisco-specific protocol extensions which may or may not work with third-party proxy or redirect servers.