WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

last login time for a user

 
   Home -> Windows Other -> Active Directory RSS
Next:  Ensoniq Creative AudioPCI sound card autoexec.bat..  
Author Message
none

External


Since: Jun 22, 2008
Posts: 1



(Msg. 1) Posted: Sun Jun 22, 2008 11:21 pm
Post subject: last login time for a user
Archived from groups: microsoft>public>win2000>active_directory (more info?)

Hello,

I'm required to show last login times for a user when they login to a
server running Windows Server 2003. I'm trying to use the script at the
end of this message to query the DIT and retrieve the value of
lastLogonTimestamp for the user currently logging in. The script I'm
using is a common script that is found on many websites and the VBscript
version comes from the WIndows Server Cookbook. The problem I'm having
is that the script always returns Dec 31 1969 despite the fact that the
domain administrator account I'm querying just logged in because I'm
running the script as the domain administrator account for test purposes.

One version of the script uses subtraction on the "- $objLogon->LowPart"
but I tried that and it doesn't change the printed value.

Modifying the last 2 $intLogonTime lines at the end of the script don't
even change the printed value either. I'm not sure why this is
happening. Can anyone help? The value is being set. I verified using
ADSI Edit.


# ------ SCRIPT CONFIGURATION ------
my $strUserDN = "<UserDN>"; # e.g. cn=rallen,ou=Sales,dc=rallencorp,dc=com
# ------ END CONFIGURATION ---------
use Win32::OLE;
$Win32::OLE::Warn = 3;
my $objUser = Win32::OLE->GetObject("LDAP://" . $strUserDN);
my $objLogon = $objUser->Get("lastLogonTimestamp");
my $intLogonTime = ($objLogon->HighPart * 232) + $objLogon->LowPart;
$intLogonTime = $intLogonTime / (60 * 10000000);
$intLogonTime = $intLogonTime / 1440;
print "Approx last logon timestamp: ", scalar localtime($intLogonTime),"\n";
Back to top
Login to vote
Richard Mueller [MVP]

External


Since: Feb 25, 2007
Posts: 85



(Msg. 2) Posted: Mon Jun 23, 2008 7:41 am
Post subject: Re: last login time for a user [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

<none.DeleteThis@none.com> wrote in message
news:485f16b7$0$27944$4c368faf@roadrunner.com...
> Hello,
>
> I'm required to show last login times for a user when they login to a
> server running Windows Server 2003. I'm trying to use the script at the
> end of this message to query the DIT and retrieve the value of
> lastLogonTimestamp for the user currently logging in. The script I'm using
> is a common script that is found on many websites and the VBscript version
> comes from the WIndows Server Cookbook. The problem I'm having is that the
> script always returns Dec 31 1969 despite the fact that the domain
> administrator account I'm querying just logged in because I'm running the
> script as the domain administrator account for test purposes.
>
> One version of the script uses subtraction on the "- $objLogon->LowPart"
> but I tried that and it doesn't change the printed value.
>
> Modifying the last 2 $intLogonTime lines at the end of the script don't
> even change the printed value either. I'm not sure why this is happening.
> Can anyone help? The value is being set. I verified using ADSI Edit.
>
>
> # ------ SCRIPT CONFIGURATION ------
> my $strUserDN = "<UserDN>"; # e.g.
> cn=rallen,ou=Sales,dc=rallencorp,dc=com
> # ------ END CONFIGURATION ---------
> use Win32::OLE;
> $Win32::OLE::Warn = 3;
> my $objUser = Win32::OLE->GetObject("LDAP://" . $strUserDN);
> my $objLogon = $objUser->Get("lastLogonTimestamp");
> my $intLogonTime = ($objLogon->HighPart * 232) + $objLogon->LowPart;
> $intLogonTime = $intLogonTime / (60 * 10000000);
> $intLogonTime = $intLogonTime / 1440;
> print "Approx last logon timestamp: ", scalar
> localtime($intLogonTime),"\n";

The "232" in the script above should be "2^32" (2 to the 32nd power). The
final answer should be in UTC (Coordinated Universal Time, or what was once
called GMT).

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
Back to top
Login to vote
Paul Bergson [MVP-DS]

External


Since: Oct 09, 2006
Posts: 316



(Msg. 3) Posted: Wed Jun 25, 2008 7:56 am
Post subject: Re: last login time for a user [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Check out a vbscript I have maybe there is some code in there to help you
out.

http://www.pbbergs.com/windows/downloads.htm
Click on the Active Directory User Account Attributes hyperlink and it
should download for you

--
Paul Bergson
MVP - Directory Services
MCTS, MCT, MCSE, MCSA, Security+, BS CSci
2008, 2003, 2000 (Early Achiever), NT4

http://www.pbbergs.com

Please no e-mails, any questions should be posted in the NewsGroup
This posting is provided "AS IS" with no warranties, and confers no rights.

<none.DeleteThis@none.com> wrote in message
news:485f16b7$0$27944$4c368faf@roadrunner.com...
> Hello,
>
> I'm required to show last login times for a user when they login to a
> server running Windows Server 2003. I'm trying to use the script at the
> end of this message to query the DIT and retrieve the value of
> lastLogonTimestamp for the user currently logging in. The script I'm using
> is a common script that is found on many websites and the VBscript version
> comes from the WIndows Server Cookbook. The problem I'm having is that the
> script always returns Dec 31 1969 despite the fact that the domain
> administrator account I'm querying just logged in because I'm running the
> script as the domain administrator account for test purposes.
>
> One version of the script uses subtraction on the "- $objLogon->LowPart"
> but I tried that and it doesn't change the printed value.
>
> Modifying the last 2 $intLogonTime lines at the end of the script don't
> even change the printed value either. I'm not sure why this is happening.
> Can anyone help? The value is being set. I verified using ADSI Edit.
>
>
> # ------ SCRIPT CONFIGURATION ------
> my $strUserDN = "<UserDN>"; # e.g.
> cn=rallen,ou=Sales,dc=rallencorp,dc=com
> # ------ END CONFIGURATION ---------
> use Win32::OLE;
> $Win32::OLE::Warn = 3;
> my $objUser = Win32::OLE->GetObject("LDAP://" . $strUserDN);
> my $objLogon = $objUser->Get("lastLogonTimestamp");
> my $intLogonTime = ($objLogon->HighPart * 232) + $objLogon->LowPart;
> $intLogonTime = $intLogonTime / (60 * 10000000);
> $intLogonTime = $intLogonTime / 1440;
> print "Approx last logon timestamp: ", scalar
> localtime($intLogonTime),"\n";
Back to top
Login to vote
Brandon McCombs

External


Since: Sep 26, 2005
Posts: 86



(Msg. 4) Posted: Fri Jun 27, 2008 8:05 pm
Post subject: Re: last login time for a user [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Richard Mueller [MVP] wrote:
> <none.RemoveThis@none.com> wrote in message
> news:485f16b7$0$27944$4c368faf@roadrunner.com...
>> Hello,
>>
>> I'm required to show last login times for a user when they login to a
>> server running Windows Server 2003. I'm trying to use the script at the
>> end of this message to query the DIT and retrieve the value of
>> lastLogonTimestamp for the user currently logging in. The script I'm using
>> is a common script that is found on many websites and the VBscript version
>> comes from the WIndows Server Cookbook. The problem I'm having is that the
>> script always returns Dec 31 1969 despite the fact that the domain
>> administrator account I'm querying just logged in because I'm running the
>> script as the domain administrator account for test purposes.
>>
>> One version of the script uses subtraction on the "- $objLogon->LowPart"
>> but I tried that and it doesn't change the printed value.
>>
>> Modifying the last 2 $intLogonTime lines at the end of the script don't
>> even change the printed value either. I'm not sure why this is happening.
>> Can anyone help? The value is being set. I verified using ADSI Edit.
>>
>>
>> # ------ SCRIPT CONFIGURATION ------
>> my $strUserDN = "<UserDN>"; # e.g.
>> cn=rallen,ou=Sales,dc=rallencorp,dc=com
>> # ------ END CONFIGURATION ---------
>> use Win32::OLE;
>> $Win32::OLE::Warn = 3;
>> my $objUser = Win32::OLE->GetObject("LDAP://" . $strUserDN);
>> my $objLogon = $objUser->Get("lastLogonTimestamp");
>> my $intLogonTime = ($objLogon->HighPart * 232) + $objLogon->LowPart;
>> $intLogonTime = $intLogonTime / (60 * 10000000);
>> $intLogonTime = $intLogonTime / 1440;
>> print "Approx last logon timestamp: ", scalar
>> localtime($intLogonTime),"\n";
>
> The "232" in the script above should be "2^32" (2 to the 32nd power). The
> final answer should be in UTC (Coordinated Universal Time, or what was once
> called GMT).
>

I forgot to verify the script pasted into the email okay. I already have
2^32 in the script. It just didn't paste in correctly to Thunderbird for
some reason.
Back to top
Login to vote
Mumin CICEK

External


Since: Jul 29, 2008
Posts: 2



(Msg. 5) Posted: Tue Jul 29, 2008 3:26 pm
Post subject: Re: last login time for a user [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

There is a program for that is called "Last Logon". you can use it.


<none.DeleteThis@none.com> wrote in message
news:485f16b7$0$27944$4c368faf@roadrunner.com...
> Hello,
>
> I'm required to show last login times for a user when they login to a
> server running Windows Server 2003. I'm trying to use the script at the
> end of this message to query the DIT and retrieve the value of
> lastLogonTimestamp for the user currently logging in. The script I'm using
> is a common script that is found on many websites and the VBscript version
> comes from the WIndows Server Cookbook. The problem I'm having is that the
> script always returns Dec 31 1969 despite the fact that the domain
> administrator account I'm querying just logged in because I'm running the
> script as the domain administrator account for test purposes.
>
> One version of the script uses subtraction on the "- $objLogon->LowPart"
> but I tried that and it doesn't change the printed value.
>
> Modifying the last 2 $intLogonTime lines at the end of the script don't
> even change the printed value either. I'm not sure why this is happening.
> Can anyone help? The value is being set. I verified using ADSI Edit.
>
>
> # ------ SCRIPT CONFIGURATION ------
> my $strUserDN = "<UserDN>"; # e.g.
> cn=rallen,ou=Sales,dc=rallencorp,dc=com
> # ------ END CONFIGURATION ---------
> use Win32::OLE;
> $Win32::OLE::Warn = 3;
> my $objUser = Win32::OLE->GetObject("LDAP://" . $strUserDN);
> my $objLogon = $objUser->Get("lastLogonTimestamp");
> my $intLogonTime = ($objLogon->HighPart * 232) + $objLogon->LowPart;
> $intLogonTime = $intLogonTime / (60 * 10000000);
> $intLogonTime = $intLogonTime / 1440;
> print "Approx last logon timestamp: ", scalar
> localtime($intLogonTime),"\n";
Back to top
Login to vote
Jorge de Almeida Pinto [M

External


Since: Aug 22, 2006
Posts: 307



(Msg. 6) Posted: Sun Aug 03, 2008 1:53 pm
Post subject: Re: last login time for a user [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

see if you can use the OLDCMP tool from joeware.net

--

Cheers,
(HOPEFULLY THIS INFORMATION HELPS YOU!)

# Jorge de Almeida Pinto # MVP Identity & Access - Directory Services #

BLOG (WEB-BASED)--> http://blogs.dirteam.com/blogs/jorge/default.aspx
BLOG (RSS-FEEDS)--> http://blogs.dirteam.com/blogs/jorge/rss.aspx
------------------------------------------------------------------------------------------
* How to ask a question --> http://support.microsoft.com/?id=555375
------------------------------------------------------------------------------------------
* This posting is provided "AS IS" with no warranties and confers no rights!
* Always test ANY suggestion in a test environment before implementing!
------------------------------------------------------------------------------------------
#################################################
#################################################
------------------------------------------------------------------------------------------
"Mumin CICEK" <mumin.cicek RemoveThis @akademinet.net> wrote in message
news:O6Gt9XX8IHA.4988@TK2MSFTNGP04.phx.gbl...
> There is a program for that is called "Last Logon". you can use it.
>
>
> <none RemoveThis @none.com> wrote in message
> news:485f16b7$0$27944$4c368faf@roadrunner.com...
>> Hello,
>>
>> I'm required to show last login times for a user when they login to a
>> server running Windows Server 2003. I'm trying to use the script at the
>> end of this message to query the DIT and retrieve the value of
>> lastLogonTimestamp for the user currently logging in. The script I'm
>> using is a common script that is found on many websites and the VBscript
>> version comes from the WIndows Server Cookbook. The problem I'm having is
>> that the script always returns Dec 31 1969 despite the fact that the
>> domain administrator account I'm querying just logged in because I'm
>> running the script as the domain administrator account for test purposes.
>>
>> One version of the script uses subtraction on the "- $objLogon->LowPart"
>> but I tried that and it doesn't change the printed value.
>>
>> Modifying the last 2 $intLogonTime lines at the end of the script don't
>> even change the printed value either. I'm not sure why this is happening.
>> Can anyone help? The value is being set. I verified using ADSI Edit.
>>
>>
>> # ------ SCRIPT CONFIGURATION ------
>> my $strUserDN = "<UserDN>"; # e.g.
>> cn=rallen,ou=Sales,dc=rallencorp,dc=com
>> # ------ END CONFIGURATION ---------
>> use Win32::OLE;
>> $Win32::OLE::Warn = 3;
>> my $objUser = Win32::OLE->GetObject("LDAP://" . $strUserDN);
>> my $objLogon = $objUser->Get("lastLogonTimestamp");
>> my $intLogonTime = ($objLogon->HighPart * 232) + $objLogon->LowPart;
>> $intLogonTime = $intLogonTime / (60 * 10000000);
>> $intLogonTime = $intLogonTime / 1440;
>> print "Approx last logon timestamp: ", scalar
>> localtime($intLogonTime),"\n";
>
>
Back to top
Login to vote
Display posts from previous:   
       Home -> Windows Other -> Active Directory All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
  Windows Other
 Office
 Office Other
 Security
 WinRAR
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET