You need to change the account your code runs under in IIS to one that has the access you need, the default account can't access the network. Just remember it opens up security risks as any exploits found in your code are now run under that elevated account and could potentially be far more serious.
What you have to change exactly and how depends on your version of IIS and how your site is set up so google for more info if this doesn't help
Configure the Anonymous Authentication Identity (IIS 7)[
^]