Advertisement
Guest User

Untitled

a guest
Jan 11th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.67 KB | None | 0 0
  1. use Win32::OLE 'in';
  2. use Win32::OLE::Const 'Active DS Type Library';
  3. $Win32::OLE::Warn = 3;
  4.  
  5. $RootObj = bind_object("RootDSE");
  6. $SchemaClasses = bind_object($RootObj->get("schemaNamingContext"));
  7. $AbstractClasses = bind_object("schema");
  8.  
  9. $con = Win32::OLE->new("ADODB.Connection");
  10. $con->{Provider} = "ADsDSOObject";
  11. $con->{Properties}->{"User ID"} = "Interim A";
  12. $con->{Properties}->{"Password"} = "Interim A";
  13. $con->{Properties}->{"Encrypt Password"} = True;
  14. $con->Open();
  15.  
  16. $command = Win32::OLE->new("ADODB.Command");
  17. $command->{ActiveConnection} = $con;
  18. $command->{Properties}->{"Page Size"} = 20;
  19.  
  20. $sBase = $SchemaClasses->{adspath};
  21. $sFilter = "(|(auxiliaryClass=*)(systemAuxiliaryClass=*))";
  22. $sAttr = "ldapdisplayname,cn,auxiliaryClass,systemAuxiliaryClass";
  23. $sScope = "Subtree";
  24.  
  25. $command->{CommandText} = "<$sBase>;$sFilter;$sAttr;$sScope";
  26. $rs = $command->Execute();
  27.  
  28. until($rs->{EOF}){
  29.     $aantal = 0;
  30.     $aantal+= scalar @{$rs->Fields("auxiliaryClass")->{Value}};
  31.     $aantal+= scalar @{$rs->Fields("systemAuxiliaryClass")->{Value}};
  32.     print $rs->Fields('ldapdisplayname')->{Value}, " heeft $aantal aux classes\n";
  33.     print "\t";
  34.     print join "\n\t", @{$rs->Fields("auxiliaryClass")->{Value}}, "\n\t";
  35.     print join "\n\t", @{$rs->Fields("systemAuxiliaryClass")->{Value}};
  36.     print "\n";
  37.     $rs->MoveNext();
  38. }
  39.  
  40. $rs->Close();
  41. $con->Close();
  42.  
  43.  
  44. sub bind_object{
  45.     $parameter=shift;
  46.     $ip = "satan.hogent.be";
  47.     $moniker = ( (substr( uc($parameter), 0, 7) ) eq "LDAP://" ? "" : "LDAP://$ip/" ) . $parameter;
  48.     # print $moniker,"\n";
  49.     $dso = Win32::OLE->GetObject("LDAP:");
  50.     $user = "Interim A";
  51.     return $dso->OpenDSObject($moniker, $user, $user, ADS_SECURE_AUTHENTICATION);
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement