I've tried passing the appropriate username and password when creating the DirectoryEntry instance, however, it acts the exact same way as without it; when executed against my local machine it works fine, against a remote machine, it doesn't work. Even if I enable DMZ on my router and forward all calls to my machine and then execute the code against my external IP it throws the same error. Also, I would think that if the problem was invalid user credentials it would throw a different error (something relating to incorrect permissions).
Concerning the try...catch block: it doesn't work. I've tried numerous ways around it and it's a very, very odd thing. If I replace my catch block with:
catch(COMException ex) { ... }
or even:
catch { ... }
it skips right over it and throws the error (instead of executing the code in catch block). I'm guessing it might be a bug related to poor exception handling for unmanaged code.
Main Topics
Browse All Topics





by: dunglaPosted on 2005-04-26 at 23:21:57ID: 13873474
When you input IP address of another computer, your code will make a RPC call to remote machine (specified by IP, computer name). At remote machine, when your code prepare to executed, that machine will check for authorization of user who execute the code (mean your account in your local machine). If not authorized then the code will thru exeception.
irectoryEn try iisRoot = new System.DirectoryServices.D irectoryEn try("IIS:/ /" + serverAddress + "/W3SVC/1/Root", "username", "password");
You can try...catch (COMException ex) for more detail. When you create new instance of DirectoryEntry, remember to parse username and password as well
System.DirectoryServices.D