Hi,
I am developing a script which has to authenticate against MS Active Directory. I am using the following script for that.
#!/usr/bin/perl use Net::LDAP; use Data::Dumper; use Net::LDAP::Util qw(ldap_error_text ldap_error_name ldap_error_desc ); my $LDAPServerAddress = '10.4.78.107'; my $errorMsg=checkPassword('test@navitools.com','test'); print "$errorMsg....."; sub checkPassword() { my ($user,$password)=@_; my $ldap = Net::LDAP->new($LDAPServerAddress, port => '636',scheme = +> 'ldaps') || return "Can't connect to $LDAPServerAddress via LDAP" +; my $result=$ldap->bind("CN=Test User,OU=Corp, DC=navitools,DC=com",p +assword=>$password) || die "$@"; $ldap->unbind(); $result->code && return $result->error; # return error message if fa +iled return 1; # return "undef" on success }

My problem is in bind part.This script works fine. But here I am using the attribute CN=Test User (1st & last name) and the password .

I have to use logon name to get authenticated (test). If i use 'CN=test' instead of 'CN=Test User ', its not authenticating.
Please help me to get it done.
Thanks,

In reply to Active Directory authentication using login name by Anonymous Monk

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.