2

I use the following code to get the value of the attribute NAME of an AD computer object:

$compObj = Win32::OLE->GetObject("LDAP://cn=$computername,dc=test,dc=com");
print "$compObj->{Name}";

How can I get information of all the attributes stored in the object? I miss a method like a dump function or something like that. How can I find out which possible attributes are existent?

1 Answers1

1

use:

foreach $key (keys %$compObj){
  print $key."\n";
}
Jens
  • 67,715
  • 15
  • 98
  • 113
  • Thanks Jens. First, I changed it to `foreach $key (keys %compObj)` without the Dollar. But unfortunately the outputs keeps being empty. I do not understand why ... –  Dec 14 '15 at 06:08
  • @Hamstibamsti Because `$compObj`is a reference to a hash and has to be dereferenced. `%compObj` is a new hash – Jens Dec 14 '15 at 06:15
  • Thanks again for responding. Your explanation is very good. Thanks. Unfortunately the output is still empty ... :-( –  Dec 14 '15 at 07:08
  • @Hamstibamsti then use Data:Dumper to see the Content of `$compObj` – Jens Dec 14 '15 at 07:09