Archived
1
0
This repository has been archived on 2021-10-08. You can view files and clone it, but cannot push or open issues or pull requests.
ACU/commands/ldap/extract_students.pl
2013-09-06 09:49:55 +02:00

38 lines
646 B
Perl

#! /usr/bin/env perl
use v5.10.1;
use strict;
use warnings;
use Pod::Usage;
use lib "../../";
use ACU::Log;
use ACU::LDAP;
sub get_students()
{
my $ldap = LDAP::ldap_connect();
my $year = LDAP::get_year($ldap);
return LDAP::search_dns($ldap, "ou=$year,ou=users", "objectClass=epitaAccount", "cn", "uid", "uidNumber");
}
if ($#ARGV == -1) {
log(USAGE, "$0 format");
say "format can be csv"
}
elsif ($ARGV[0] eq "csv")
{
for my $student (get_students)
{
print $student->get_value("cn");
print ",";
print $student->get_value("uid");
print ",";
print $student->get_value("uidNumber");
say ",Present";
}
}