For Programmers: Free Programming Magazines  


Home > Archive > LDAP > May 2006 > Authen::SASL::Perl::GSSAPI documentaion: Codeexample









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Authen::SASL::Perl::GSSAPI documentaion: Codeexample
Achim Grolms

2006-05-10, 7:11 pm

Hello,

=46rom my pint of view the POD of Authen::SASL::Perl::GSSAPI
is missing a codeexample that demonstrates how to use the
Authen::SASL::Perl::GSSAPI module.
I promised to send Code, here is an example that's used=20
with Net::LDAP and makes use of the new error() Method.
So the user has a chance to see from ducumentation how to
get helpful errormessages (from the underlying Kerberossystem).

What do you think of adding that codesnippet to the POD
of Authen::SASL::Perl::GSSAPI?

Thank you,
Achim


#! /usr/bin/perl -w

use strict;

use Net::LDAP 0.33;
use Authen::SASL 2.10;

# -------- Adjust to your environment --------
my $adhost =3D 'theserver.bla.net';
my $ldap_base =3D 'dc=3Dbla,dc=3Dnet';
my $ldap_filter =3D '(&(sAMAccountName=3DBLAAGROL))';

my $sasl =3D Authen::SASL->new( mechanism =3D> 'GSSAPI' );

my $ldap;
eval {
$ldap =3D Net::LDAP->new( $adhost,
onerror =3D> 'die',
) or die "Cannot connect to LDAP host '$adhost':=
=20
'$@'";
$ldap->bind( sasl =3D> $sasl );
};

if ($@) {
chomp $@;
die "\nBind error : $@",
"\nDetailed SASL error: ", $sasl->error,
"\nTerminated";
}

print "\nLDAP bind() succeeded, working in authenticated state";

my $mesg =3D $ldap->search( base =3D> $ldap_base,
filter =3D> $ldap_filter );

# -------- evaluate $mesg=20
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com