#!/usr/bin/perl # # Perl Net::LDAP example 1 # oozie poczta fm / Jan 2008 # # This script takes one argument from the command line and compares it # to uid= attribute under the $base tree. It assumes that only one # entry will be returned from the search # ############### use Net::LDAP; # declarations # you might want to change this part $server = "porta.tux"; $port = 389; $ldapVer = 3; $uid = $ARGV[0]; $base = "ou=People,dc=porta,dc=tux"; $filter = "(uid=$uid)"; # Business card $info = "\nLDAP Example I - uid search'n'dump\n\n"; print $info; # Code if (!$#ARGV) { # # Opening session # $ldap_handle = Net::LDAP->new($server); $result = $ldap_handle->bind(); die $result->error() if $result->code(); $msg = $ldap_handle->search( base=> $base, scope=> "sub", filter=> $filter ); if ( $msg->count() > 0 ) { $msg->entry->dump(); } # graceful exit print "bye\n"; $ldap_handle->unbind(); } else { # syntax print "Usage: ./glookup.pl \n\n"; }