Tags:
create new tag
, view all tags
#!/usr/local/bin/perl


use Net::LDAPS;

print "username =>";
my $username = <STDIN>;
chomp($username);

print "password =>";
my $password = <STDIN>;
chomp($password);

my $BASE_DN = 'ou=users,ou=nethz,ou=id,ou=auth,o=ethz,c=ch';  # SEARCH - Basis
my @hosts   = qw(ldaps01.ethz.ch ldaps02.ethz.ch ldaps03.ethz.ch);
my $ldap;

foreach my $host (@hosts) {
    $ldap = Net::LDAPS->new($host,
             port => 636,
             sslversion => 'tlsv1',
             ciphers => 'HIGH:MEDIUM:+SSLv2',
             debug => 0,
             version => 3);
    last if $ldap;
}
die "Es konnte keine Verbindung zum LDAPS-Server hergestellt werden:\n$@" unless $ldap;

# bind to a directory with dn and password
my $mesg = $ldap->bind( "cn=$username,$BASE_DN",
         password => $password );
die "Username / Passwort ist falsch\n"
    if ($mesg->code);

print "Username / Passwort ok.\n";

#--- Daten des Users anzeigen

$mesg = $ldap->search (base   => $BASE_DN,
                       filter => "uid=$username"
             );

while (my $entry = $mesg->shift_entry) {
    print $entry->dn(), "\n";
    foreach my $attr ($entry->attributes) {
   print join("\n ",$attr, $entry->get_value($attr)),"\n";
    }
}
print "--------------------------------------------\n";

$ldap->unbind;
Topic revision: r3 - 2009-11-09 - vermeul
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback