Reduce "begin ... rescue" scope

The code should not raise DistinguishedNameInvalid error.