Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I am getting Bad file descriptor error with below code for Net::LADPS.

use warnings; use strict; use Net::LDAPS; my $ldaps = Net::LDAPS->new( 'ldap server', port => '636', verify => 'require', cafile => 'C:/certicate.cer' ) or die $!; #note i have used .pem too here but failing with the same + "Bad file descriptor error" print "\nLDAPS ::: $ldaps\n";
Note : I am working on strawberry perl version (v5.32.1)

Any help with this would be appreciated.

Thank you.

Replies are listed 'Best First'.
Re: Bad file descriptor error with Net::LDAPS.
by kcott (Archbishop) on Aug 02, 2021 at 18:18 UTC

    I haven't used Net::LDAPS previously, so I looked at its doco. It has two examples with capath; cafile doesn't appear anywhere. Try s/cafile/capath/.

    — Ken

      Thank you for the reply

      Net::LDAPS seems inherit methods from Net::LDAP module which has cafile method.

      Thank you

Re: Bad file descriptor error with Net::LDAPS.
by bliako (Abbot) on Aug 03, 2021 at 09:04 UTC
    or die $!

    The official documentation at Net::LDAP shows this $ldap = Net::LDAP->new( 'ldap.example.com' )  or  die "$@"; You may be seeing a stale message left in $!, unless you are sure you saw using $! with said module somewhere.

    wild guess: probably one of the myriad of problems that can be unleashed from Microsoft HQ onto hopeful yet unsuspected windows users.

    bw, bliako

      Thank you for the reply.

      Even die "$@" throws the same error "Bad file descriptor at .pl line 5, <DATA> line 960."

      Regards

        What's 'ldap server'???? Isn't that supposed to be a hostname or an IP? I get Name or service not known at xx.pl line 5, <DATA> line 960.