Archived
1
0

Extract list of users by year

This commit is contained in:
Mercier Pierre-Olivier 2013-09-15 12:32:50 +02:00
parent e2f8d2389d
commit aebef9850e

View File

@ -10,11 +10,11 @@ use lib "../../";
use ACU::Log; use ACU::Log;
use ACU::LDAP; use ACU::LDAP;
sub get_students() sub get_students
{ {
my $ldap = LDAP::ldap_connect(); my $ldap = LDAP::ldap_connect();
my $year = LDAP::get_year($ldap); my $year = shift // LDAP::get_year($ldap);
return LDAP::search_dns($ldap, "ou=$year,ou=users", "objectClass=epitaAccount", "cn", "uid", "uidNumber"); return LDAP::search_dns($ldap, "ou=$year,ou=users", "objectClass=epitaAccount", "cn", "uid", "uidNumber");
} }
@ -25,7 +25,7 @@ if ($#ARGV == -1) {
} }
elsif ($ARGV[0] eq "csv") elsif ($ARGV[0] eq "csv")
{ {
for my $student (get_students) for my $student (get_students $ARGV[1])
{ {
print $student->get_value("cn"); print $student->get_value("cn");
print ","; print ",";