LFCS · Question #197
You're writing a simple Perl script to query an LDAP directory using the Net::LDAP module. Which method would you use to determine if the start_tls() operation was successful?
The correct answer is B. code(). To determine the success of the start_tls() operation using Perl's Net::LDAP module, one would use the code() method.
Question
Options
- Aerr()
- Bcode()
- Cresult()
- Dmsg()
How the community answered
(48 responses)- B94% (45)
- C4% (2)
- D2% (1)
Why each option
To determine the success of the `start_tls()` operation using Perl's `Net::LDAP` module, one would use the `code()` method.
`err()` returns a human-readable error string, which is less programmatic than the numerical code.
In the `Net::LDAP` Perl module, the `code()` method is used on the returned `LDAP::Message` object to retrieve the numerical LDAP result code of an operation. A result code of `LDAP_SUCCESS` (0) indicates that the `start_tls()` operation successfully established an encrypted connection.
`result()` is not the standard method for checking the success of `start_tls()` in `Net::LDAP`; it's typically used to retrieve the full result object of search or modify operations.
`msg()` returns a human-readable message, similar to `err()`, but `code()` provides the definitive numerical status.
Concept tested: Net::LDAP error handling
Source: https://metacpan.org/pod/Net::LDAP#code
Topics
Community Discussion
No community discussion yet for this question.