Not Authorised to Server

Hi,

I have an agent that checks whether I can create a session on a server. I run it manually from my work station. All I want it to do is to check whether the server is up. To some servers I do not have access, which is fine because I only want to know whether the server is up. The problem is that the code doesn’t throw an error when I do not have access, therefore I cannot distinguish between “not authorised” and “cannot find server”.

Does anybody know a way to find out (programmatically) the difference between “Not authorised” and “cannot find server”?