Add a command to extract students
This commit is contained in:
parent
9819f763f6
commit
706c10a2bb
37
commands/ldap/extract_students.pl
Normal file
37
commands/ldap/extract_students.pl
Normal 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";
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user