my $objUser = eval { Win32::OLE->GetObject("LDAP://$path") }; # now, $objUser will either be an object (if it worked), or # undef (if it didn't work).