Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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 example.com 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 ldap_compare.pl 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.

Srinivas.


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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2022-08-17 16:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?