if ( $nt->login($server,$name,$pass) ) { # do things $nt->logout(); } else { report("Failed logging in to $server: " . $nt->errmsg); }