. . . # implementatie functie bind_object: zie reeks 6, oefening 4
my $ADOconnection = Win32::OLE->CreateObject("ADODB.Connection");
$ADOconnection->{Provider} = "ADsDSOObject";
$ADOconnection->{Properties}->{"User ID"} = ". . ."; # vul in of zet in commentaar
$ADOconnection->{Properties}->{"Password"} = ". . ."; # vul in of zet in commentaar
$ADOconnection->{Properties}->{"Encrypt Password"} = True;
$ADOconnection->Open(); # mag je niet vergeten
my $ADOcommand = Win32::OLE->CreateObject("ADODB.Command");
$ADOcommand->{ActiveConnection} = $ADOconnection; # verwijst naar het voorgaand object
$ADOcommand->{Properties}->{"Page Size"} = 20;
my $sBase = "LDAP://";
$sBase .= "193.190.126.71/" unless (uc($ENV{USERDOMAIN}) eq "III"); # als je niet in het domein zelf zit
$sBase .= "OU=iii,DC=iii,DC=hogent,DC=be";
my $sFilter = "(samAccountName=*)";
my $sAttributes = "samAccountName,objectcategory";
my $sScope = "subtree";
$ADOcommand->{CommandText} = "<$sBase>;$sFilter;$sAttributes;$sScope";
my $ADOrecordset = $ADOcommand->Execute();
my @sam;
my %cat;
until ( $ADOrecordset->{EOF} ) {
push @sam,$ADOrecordset->Fields("samAccountName")->{Value};
$ADOrecordset->Fields("objectcategory")->{Value} =~ /.*?=(.*?),/;
$cat{$1}=undef;
$ADOrecordset->MoveNext();
}
$ADOrecordset->Close();
$ADOconnection->Close();
print "Alle waarden van samAccount in het domein:\n\t",join ("\n\t",sort @sam),"\n";
print "samAccountName komt voor in klassen met objectcategorie::\n\t",join ("\n\t",sort keys %cat),"\n";