#!/usr/bin/perl -Tw
use Net::LDAP;
use strict;
use lib "/home/hawker-scripts";

use ldaputils;
$ENV{'PATH'} = '/bin:/usr/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
                                                                                                                                                             

my $basedn = 'dc=hawkerc,dc=net';
my $ldap_host = 'ldap-master.internal.hawkerc.net';
my $ldap = Net::LDAP->new($ldap_host);
$ldap->bind("") || die "bind failed!";
                                                                                                                                                             
print "Connected to $ldap_host\n";
                                                                                                                                                             
my $admin_dn = ldaputils::get_admin_dn($ldap, $basedn);
my $admin_pw = ldaputils::get_admin_pw($admin_dn);

# bind to a directory with dn and password
        $ldap->bind ( $admin_dn,
                     password => $admin_pw
		      ) or die "$@";

my $mesg = $ldap->search (  # perform a search
                               base   => $basedn,
                               filter => "(&(uid=*)(hawkerInternetUsage=*))"
			  );

$mesg->code && die $mesg->error;

foreach my $entry ($mesg->all_entries) { 
    my $dn = $entry->dn;

    print "$dn\n";

#    $ldap->modify( $dn, delete => [qw(hawkerInternetQuota)]);

    my $result = $ldap->modify( $dn, delete => [qw(hawkerInternetUsage)]);
	$result->code && die $result->error;

}
