473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

how to return dn from a search in perl and net::ldap?

147 100+
hi,

Please see my code as given below:
Expand|Select|Wrap|Line Numbers
  1. #!c:/perl/bin/perl
  2. use strict;
  3. use warnings;
  4. use CGI qw(:all);    #use for all code
  5. use Net::LDAP;
  6. use Net::LDAP::Util qw(ldap_error_name
  7.                        ldap_error_text); #use for Error Handling
  8. print "Content-type: text/html\n\n";
  9. print "<body bgcolor=\"#ffcccc\">";
  10.  
  11.  
  12. my $entry;
  13. my @uids;
  14.  
  15. my $serverlogin='administrator';
  16. my $serverpassword='xxxxx';
  17. my $LDAP_SERVER="localhost";
  18. my $LDAP_PORT="389";
  19.  
  20. my $LDAP_BASE="ou=student,dc=ac,dc=in";
  21.  
  22. #INITIALIZING
  23. my $ldap=Net::LDAP->new($LDAP_SERVER,port=>$LDAP_PORT) or die "Unable to connect to LDAP server $LDAP_SERVER: $@\n";
  24.  
  25.  
  26.  
  27.  
  28. #BINDING
  29.  
  30. my $studentlogin='CE34';
  31. my $studentpassword='c6';
  32.  
  33. my $binddn = "uid=$studentlogin, ou=student, dc=ac,dc=in";
  34. my $result = $ldap->bind(uid => $binddn, password => $studentpassword,version=>3);
  35. die $result ->error() if $result ->code();
  36.  
  37. my $mesg= $ldap->search(filter=>"(&(uid=$studentlogin)(objectClass=student))", 
  38.                         base=>$LDAP_BASE);
  39.  
  40.  
  41. if ($mesg->count()>0)
  42. {
  43.     print $mesg->count(),"entries returned.\n";
  44.     foreach $entry($mesg->all_entries())
  45.     {
  46.          $entry->dump();
  47.     }
  48. }
  49. print "</body>";
  50. print "</html>";
  51.  

and then try to get the dn (since nothing is returned, I'm guessing this is something that net::ldap doesn't return). My ldap search() is not returning any results. I don't know, whether my program is correct or not. Please help me out.Thanks in advance
Mar 14 '11 #1
2 2455
numberwhun
3,509 Expert Mod 2GB
Bear with me as I have never played with this module, but in the example from the CPAN module page, it shows the "base=>" before the "filter=>". When specifying parameters there are a lot of functions that have specific order. Have you tried reversing these?

Regards,

Jeff
Mar 14 '11 #2
santhanalakshmi
147 100+
yes, i have tried the same one. what you have told me? Please check my coding, i don't know, what mistake did i made? Please check my BINDING?

What is meant by an anonymous bind? In my code, i am not using an anonymous bind
?

What is the 'cn', the 'uid' and the 'dn'? What we should use in binding? In my below coding, i have used 'uid'(It means, the students loginname getting from the textbox)
What is the purpose of 'cn'? How can i check my binding its correct or not ?

Expand|Select|Wrap|Line Numbers
  1. my $binddn = "uid=$studentlogin, ou=student, dc=ac,dc=in";
  2. my $result = $ldap->bind(uid => $binddn, password => $studentpassword,version=>3);
  3. die $result ->error() if $result ->code();
  4.  
Mar 14 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Dirk Hagemann | last post by:
Hi! I asked here a few weeks ago the same question but the answer of Tim Golden didn't really help yet. I'd like to know how to set up a query for all computer-accounts in a special part of...
0
by: Durairaj Avasi | last post by:
Here is my prg:::: use Net::LDAP qw(LDAP_SUCCESS LDAP_PROTOCOL_ERROR); use Authen::SASL; use Net::LDAP::Util qw(ldap_error_name ldap_error_text); sub lConnect { my $server = shift; print "...
1
by: | last post by:
I have the following code to show all members of a domain global group that is selected from a drop down list. I can display the property "member" just fine which shows a listing like: ...
1
by: Big E | last post by:
I'm using ASP.net, LDAP, and SQL Server. We are using forms security for most of the ASP.Net internet site. So it uses the generic ASPuser account but then uses forms security to check SQL Server...
3
by: Dennis Dobslaf | last post by:
I try to do some authentication with LDAP. But it's a bit different to the sample in msdn. I wrote a class LdapAuthentication with a method public bool IsAuthenticated(String domain, String...
5
by: MDS | last post by:
Hey, First of all Best Wishes for 2004 I'm a system admin and I want to write a framework for our Helpdesk to do some daily stuff like creating mailboxes (not user related), (des)enabling SIP,...
2
by: Rosanne Rohana | last post by:
I'm trying for return user info (first name, last name, etc.) from a Netscape 4.16 LDAP server using the System.DirectoryServices. I'm able to get authenticated successfully, but when I attempt to...
8
by: Jean-Marie Vaneskahian | last post by:
Reading - Parsing Records From An LDAP LDIF File In .Net? I am in need of a .Net class that will allow for the parsing of a LDAP LDIF file. An LDIF file is the standard format for representing...
2
by: jjeanj1 | last post by:
Hi, all i am writing a perl script to do a a bulk add of users from a file and load it to LDAP $ldap = Net::LDAP->new("test.domain.com", port=>3394) or die "Can not connected to LDAP \n"; ...
1
by: sowing | last post by:
I am trying to bind to a LDAP server, but failed. Code as follow: #!/usr/bin/perl use strict; use warnings; use Net::LDAP; use Data::Dumper; use Net::LDAP::Util qw(ldap_error_name ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.