http://www.perlmonks.org?node_id=411309


in reply to AD User Exist?

A typical way to handle that are try/catch blocks, which in Perl are implemented with eval (the block form). When you wrap the call in an eval, it will trap the die, and let you inspect the result. Something like this in your case:

$path='cn=username,ou=mybase_ou,dc=computer,dc=com'; eval { $objUser = Win32::OLE->GetObject("LDAP://" . $path); }; if ($@) { # the call died, do something or another. }

You can read more about this in perlfunc, under eval.