Archived
1
0

Add a command to extract students

This commit is contained in:
Mercier Pierre-Olivier 2013-09-06 09:49:55 +02:00
parent 9819f763f6
commit 706c10a2bb

View File

@ -0,0 +1,37 @@
#! /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";
}
}