Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Newbie, AD problem

by Anonymous Monk
on May 26, 2011 at 08:34 UTC ( #906766=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

when i try to get the lastlogoff/lastlogon/whencreated properties i get smothing like this result:Win32::OLE=HASH(0x51791e8) other properties works fine, any idea why? and how to solve it?

#!/usr/bin/perl use Win32::OLE::Variant; $userObject = Win32::OLE->GetObject("LDAP://CN=<cn>,OU=<ou>,DC=bateman +,DC=co, DC=il"); $data1 = $userObject->{lastlogoff}; print $data1;

Replies are listed 'Best First'.
Re: Newbie, AD problem
by bingos (Vicar) on May 26, 2011 at 10:10 UTC

    lastLogon is stored as a large integer that represents the number of 100 nanosecond intervals since January 1, 1601 (UTC). A value of zero means that the last logon time is unknown.

    I use an incantation like follows to get date type values out of AD:

    sub msqtime2perl { # MicroSoft QuadTime to Perl my $foo = shift; my ($high,$low) = map { $foo->{ $_ } } qw(HighPart LowPart); return unless $high and $low; return ((unpack("L",pack("L",$low)) + unpack("L",pack("L",$high)) * (2 ** 32))) / 10000000) - 11644473600; } if ( $userObject->{lastLogon} and $userObject->{lastLogon}->{HighPart} + ) { $epochtime = msqtime2perl( $userObject->{lastLogon} ); }
Re: Newbie, AD problem
by choroba (Archbishop) on May 26, 2011 at 08:38 UTC
      keep getting : $VAR1 = bless( do{\(my $o = 52933736)}, 'Win32::OLE::Variant' ); 52933736 - change every time i run the script any other ideas?
Re: Newbie, AD problem
by Ratazong (Monsignor) on May 26, 2011 at 09:12 UTC

    If you want to read a date from an excel cell using WIN32::OLE, you should use the following

    my $date = $Sheet->Range($r)->{FormulaR1C1}; # dont use Value for +dates
    Possibly you have to do something similar for the properties ...

    HTH, Rata

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://906766]
Approved by SilasTheMonk
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2021-04-23 03:25 GMT
Find Nodes?
    Voting Booth?

    No recent polls found