20070612 ldaps with netldap - plembo/onemoretech GitHub Wiki

title: LDAPS with Net::LDAP link: https://onemoretech.wordpress.com/2007/06/12/ldaps-with-netldap/ author: lembobro description: post_id: 687 created: 2007/06/12 18:11:00 created_gmt: 2007/06/12 18:11:00 comment_status: open post_name: ldaps-with-netldap status: publish post_type: post

LDAPS with Net::LDAP

This is an article from my old personal site.

This script is an example of how to make an LDAP over SSL connection. LDAPS requires a special secure port, usually TCP port 636. The target server in this instance is a Microsoft Active Directory domain controller that has been SSL enabled (a configuration discussed in another article).

`

#!/usr/bin/perl

our($adHost,$adAdmin,$adPass);
require "../etc/ldap.inc";

my $basedn = "DC=test,DC=example,DC=com";
my @attrs = qw(cn sn givenname uid mail unicodepwd);
my $query = "(cn=Administrator)";

my $ldaps = Net::LDAP->new( "ldaps://$adHost" ) or die "$@";

my $mesg = $ldaps->bind($adAdmin, password => $adPass) or die "$@";

$mesg = $ldaps-> search (
         base => $basedn,
         scope => 'sub',
         filter => $query,
         attrs => @attrs
 );

while (my $entry = $mesg-> shift_entry()) {

   $entry-> dump;

}

$ldaps-> unbind;
	
__END__;

`

Copyright 2004-2019 Phil Lembo