LX0-104 · 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(). In Perl's Net::LDAP module, the code() method is used to retrieve the LDAP result code of an operation, which indicates its success or failure.
Question
Options
- Aerr()
- Bcode()
- Cresult()
- Dmsg()
How the community answered
(40 responses)- A3% (1)
- B90% (36)
- C3% (1)
- D5% (2)
Why each option
In Perl's Net::LDAP module, the `code()` method is used to retrieve the LDAP result code of an operation, which indicates its success or failure.
The `err()` method returns a descriptive error string, which is useful for debugging but not the primary way to programmatically check for success or failure; the numeric code is more reliable.
After performing an LDAP operation like `start_tls()` with the Perl Net::LDAP module, the `code()` method returns the numeric LDAP result code. A code of 0 (LDAP_SUCCESS) indicates the operation was successful, while other codes signify errors.
There is no standard `result()` method in `Net::LDAP` for directly checking general operation success in this manner; operations return an object on which `code()` is called.
The `msg()` method returns the error message (similar to `err()`) associated with the LDAP result, not the success/failure code itself.
Concept tested: Net::LDAP error handling (code method)
Source: https://metacpan.org/pod/Net::LDAP
Topics
Community Discussion
No community discussion yet for this question.