I am trying to bind to a Windows Active Directory LDAP server on the domain controller, via Net::LDAP. Everything works fine, I can retrieve and update values, etc.

But is there a way to invoke the Net::LDAP bind() method without supplying the user's password? I'm not talking about an anonymous bind; I want to bind with the current user's credentials and permissions, but I don't want to have to prompt the user for their password every time they run the program.

I don't know much about authentication methods, but I found some references to Authen::SASL, and various authentication mechanisms. I looked on my AD server and saw that it supports GSSAPI, so I thought I'd try that:

use Net::LDAP; use Authen::SASL; #-----------------------------------------------# # connect and authenticate #-----------------------------------------------# my $dc = 'brbdc1'; my $dn = "OU=OurDept,dc=OurDomain,dc=com"; # Create LDAP object; check auth capabilities. my $ldap = Net::LDAP->new($dc) or die; my $dse = $ldap->root_dse; die "Can't support GSSAPI" unless $dse->supported_sasl_mechanism('GSSA +PI'); # Create auth object; use it to bind to LDAP server. my $sasl = Authen::SASL->new(mechanism => 'GSSAPI') or die; my $rc = $ldap->bind(sasl => $sasl); die 'Error ' . $rc->code . ': ' . $rc->error if $rc->code;

This dies on the last line with

No SASL mechanism found at //Summ2/Perl/site/lib/Authen/SASL.pm line 77 at //Summ2/Perl/site/lib/Net/LDAP.pm line 392

I feel that I'm very close here—can anyone help?


In reply to Bind to LDAP without password by Sue D. Nymme

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.