Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hi Perl Monks,

I have been working with LDAP server configurations from some time and now I want to integrate the LDAP in my project.

I want to use LDAP to authenticate the users when they login to my portal.

I found Net::LDAP as a good perl module that can be used to serve my purpose.

I was successful in executing search statements and here is the code

#! /usr/bin/perl use Net::LDAP; $ldap = Net::LDAP->new ( "<ip address>" ) or die "Connection Failed $@ +"; $mesg = $ldap->bind ( "<user name>", password => "<password>", version => 3 ); $base = "dc=example,dc=com"; $mesg = $ldap->search ( # perform a search base => $base, filter => "(objectclass=*)" ); $mesg->code && die $mesg->error; foreach $entry ($mesg->all_entries) { $entry->dump; }
for the above code I got the following correct output:
--------------------------------------------------------------------- +--- dn:dc=example,dc=com dc: example description: Root LDAP entry for objectClass: dcObject organizationalUnit ou: rootobject ---------------------------------------------------------------------- +-- dn:ou=People,dc=example,dc=com ou: People description: All people in organisation objectClass: organizationalUnit ---------------------------------------------------------------------- +-- dn:uid=srinivas,ou=People,dc=example,dc=com uid: srinivas cn: srinivas objectClass: account posixAccount top shadowAccount userPassword: {crypt}$1$zYwJ/asE$DsYRb6CXjzJihNyTV2lC9. shadowLastChange: 13986 shadowMax: 99999 shadowWarning: 7 loginShell: /bin/bash uidNumber: 503 gidNumber: 100 homeDirectory: /home/srinivas
now when I am trying to execute compare function whose code is
$mesg = $ldap->compare( $base, attr => "uid", value => "srinivas" ); $mesg->code && die $mesg->error; foreach $entry ($mesg->all_entries) { $entry->dump; }
I am getting following error when I execute the above script
No such attribute at line 34, <DATA> line 259.
Can any one suggest whether there are any additional attributed that are to be added or any other why that I can compare my username and password for authentication. Any suggestion will be helpful.

Thanks in Advance.


In reply to Need help on Net::LDAP by srinivas_rocks

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    Jar. Jar!...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (3)
    As of 2018-05-26 03:11 GMT
    Find Nodes?
      Voting Booth?