nerdexam
Linux_Foundation

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.

Submitted by suresh_in· Apr 18, 2026Operation of Running Systems

Question

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?

Options

  • Aerr()
  • Bcode()
  • Cresult()
  • Dmsg()

How the community answered

(48 responses)
  • B
    94% (45)
  • C
    4% (2)
  • D
    2% (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.

Aerr()

`err()` returns a human-readable error string, which is less programmatic than the numerical code.

Bcode()Correct

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.

Cresult()

`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.

Dmsg()

`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

#Perl Scripting#LDAP#Net::LDAP#TLS

Community Discussion

No community discussion yet for this question.

Full LFCS Practice