in reply to
How can I get which Windows domain an IP belongs to?
Using "nbtstat" and its module equivalents can be slow, and provide incomplete information, because you need rights on the target machine. In your situation with multiple Windows domains, this may not be possible.
Assuming you have a Wins server in the environment, you can read it's entire database into memory, and match your IP's against it. The Win2K resource kit provides tools to dump database contents to STDOUT. In the old NT4 , I believe the name is "winsdump". In Win2k, (If you have a Win2k WINS server) you can use "netsh". Of course, you need admin rights on the wins server, which is a lot easier than a single account with admin rights over various domains.