<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>vbscriptblog.com &#187; lastlogon</title>
	<atom:link href="http://vbscriptblog.com/category/vbscript/active-directory/lastlogon-active-directory-vbscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://vbscriptblog.com</link>
	<description>Scripting for Windows Sysadmins</description>
	<lastBuildDate>Wed, 11 Apr 2012 07:23:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Active Directory: VBscript to enumerate the last logon of the members of a nested group with treshold</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-the-members-of-a-nested-group-with-treshold/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-the-members-of-a-nested-group-with-treshold/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 13:29:05 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[lastlogon]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[adsi]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[groups]]></category>
		<category><![CDATA[lastlogontimestamp]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[memberOf]]></category>
		<category><![CDATA[memberships]]></category>
		<category><![CDATA[nested group]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=453</guid>
		<description><![CDATA[Today I had to find out the lastlogon of the members of a nested group. Extra request was the users who&#8217;s lastlogon was longer than 90 days ago. I solved the problem by creating a script that was a combination of earlier scripts. The lastlogon code came from my lastlogon script, the enumeration of the [...]]]></description>
			<content:encoded><![CDATA[<p>Today I had to find out the lastlogon of the members of a nested group.<br />
Extra request was the users who&#8217;s lastlogon was longer than 90 days ago.<br />
I solved the problem by creating a script that was a combination of earlier scripts.<br />
The lastlogon code came from my <a href="http://deludi.nl/blog/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes-v2/">lastlogon script</a>, the enumeration of the group members code was taken from my <a href="http://deludi.nl/blog/vbscript/active-directory/groups/active-directory-vbscript-to-enumerate-the-members-of-nested-groups-v2/">enumeratenestedgroup script</a>. The users with a lastlogon of 1-1-1601 did never log on.</p>
<p>Follow the next steps to run the script (no admin rights needed):</p>
<ul>
<li>open your favorite text editor</li>
<li>copy and paste the script into the editor</li>
<li>change the distinguished name of strTargetGroupDN to the distinguished name of your nested group</li>
<li>optionally: change the treshold value in line 17 to the desired value (example treshold value is 90 days)</li>
<li>save the script (for example c:tempenumerate-lastlogon-nestedgroup-with-treshold.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:temp&#8221;</li>
<li>give &#8220;cscript enumerate-lastlogon-nestedgroup-with-treshold.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : enumerate-lastlogon-nestedgroup-with-treshold.vbs
' Description : script to enumerate the last logon of the members of a nested group with treshold
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 23-03-2010
' Level : advanced

intBias = TimeZoneBias
strTargetGroupDN = &quot;LDAP://CN=Testgroup,OU=Groups,DC=Test,DC=org&quot;
EnumNestedgroup strTargetGroupDN
Sub EnumNestedgroup(strGroupDN)
	Set objGroup = GetObject(strGroupDN)
	For Each objMember in objGroup.Members
		If (LCase(objMember.Class) = &quot;group&quot;) Then
			EnumNestedgroup objMember.AdsPath
		Else
			CheckLastLoginWithTreshold objMember.AdsPath, 90
		End If
	Next
	Set objGroup = Nothing
End Sub

Sub CheckLastLoginWithTreshold(strDN,intTreshold)
	Set objUser = GetObject(strDN)
	On Error resume next
	Set objDate = objUser.Get(&quot;lastLogonTimestamp&quot;)
	If (Err.Number &lt;&gt; 0) Then
        dtmDate = #1/1/1601#
    Else
		dtmDate = ((((objDate.Highpart * (2^32)) + objDate.LowPart)/(600000000 - intBias))/1440) + #1/1/1601#
	End If
	Set objDate = Nothing
	If DateDiff(&quot;d&quot;,dtmDate,Date) &gt; intTreshold Then
		Wscript.Echo objUser.Displayname &amp; &quot; ; &quot; &amp; objUser.Mail &amp; &quot; ; &quot; &amp; dtmDate
	End If
	Set objUser = Nothing
End Sub

Function TimeZoneBias
	strComputer = &quot;.&quot;
	Set objWMIService = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\&quot; &amp; strComputer &amp; &quot;rootcimv2&quot;)
	Set colTimeZone = objWMIService.ExecQuery(&quot;Select * from Win32_TimeZone&quot;)
	For Each objTimeZone in colTimeZone
		TimeZoneBias = objTimeZone.Bias
	Next
	Set colTimeZone = Nothing
	Set objWMIService = Nothing
End Function
</pre>
<p>When you have problems/questions please post a reply.</p>
<p>Happy scripting.</p>
<p>Best regards,</p>
<p>Dirk Adamsky &#8211; Deludi BV</p>
<p>&nbsp;</p>
<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fvbscriptblog.com%2Fvbscript%2Factive-directory%2Flastlogon-active-directory-vbscript%2Factive-directory-vbscript-to-enumerate-the-last-logon-of-the-members-of-a-nested-group-with-treshold%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-the-members-of-a-nested-group-with-treshold/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-the-members-of-a-nested-group-with-treshold/"  data-text="Active Directory: VBscript to enumerate the last logon of the members of a nested group with treshold" data-count="horizontal" data-via="dirkadamsky"></a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-the-members-of-a-nested-group-with-treshold/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-the-members-of-a-nested-group-with-treshold/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Active Directory: VBscript to enumerate the last logon of all AD users and a lot of user attributes V2</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes-v2/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes-v2/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 13:03:57 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[lastlogon]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[bias]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[lastlogontimestamp]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[Win32_TimeZone]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=421</guid>
		<description><![CDATA[This script is a further development of my previous lastlogon script. Changes are: time bias with wmi, less code, array based attributes. By adding extra attributes to the arrAttributes array you can expand the output. Follow the next steps to run the script (no admin rights needed): * open your favorite text editor * copy [...]]]></description>
			<content:encoded><![CDATA[<p>This script is a further development of my <a href="http://deludi.nl/blog/category/vbscript/active-directory/lastlogon-active-directory-vbscript/">previous lastlogon script.</a><br />
Changes are: time bias with wmi, less code, array based attributes.<br />
By adding extra attributes to the arrAttributes array you can expand the output.</p>
<p>Follow the next steps to run the script (no admin rights needed):</p>
<p>* open your favorite text editor<br />
* copy and paste the script into the editor<br />
* save the script (for example c:\temp\enumerate-lastlogon-details2.vbs)<br />
* open a command prompt<br />
* go to &#8220;c:\temp&#8221;<br />
* give &#8220;cscript enumerate-lastlogon-details2.vbs&#8221; (without quotes) and enter</p>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : enumerate-lastlogon-details2.vbs
' Description : script to enumerate the last logon of all AD users and a lot of user attributes V2
' Author : dirk adamsky - deludi bv
' Version : 2.00
' Date : 12-03-2010
' Level : advanced

intBias = TimeZoneBias
arrAttributes = Array(&quot;lastLogonTimeStamp&quot;,&quot;displayname&quot;,&quot;mail&quot;)

Set adoCommand = CreateObject(&quot;ADODB.Command&quot;)
Set adoConnection = CreateObject(&quot;ADODB.Connection&quot;)
adoConnection.Provider = &quot;ADsDSOObject&quot;
adoConnection.Open &quot;Active Directory Provider&quot;
adoCommand.ActiveConnection = adoConnection

Set objRootDSE = GetObject(&quot;LDAP://RootDSE&quot;)
strBase = &quot;&lt;LDAP://&quot; &amp; objRootDSE.Get(&quot;defaultNamingContext&quot;) &amp; &quot;&gt;&quot;
Set objRootDSE = Nothing

strFilter = &quot;(&amp;(objectCategory=person)(objectClass=user))&quot;
strAttributes = Join(arrAttributes,&quot;,&quot;)
Wscript.Echo Join(arrAttributes,&quot;;&quot;)
strQuery = strBase &amp; &quot;;&quot; &amp; strFilter &amp; &quot;;&quot; &amp; strAttributes &amp; &quot;;subtree&quot;
adoCommand.CommandText = strQuery
adoCommand.Properties(&quot;Page Size&quot;) = 100
adoCommand.Properties(&quot;Timeout&quot;) = 30
adoCommand.Properties(&quot;Cache Results&quot;) = False
Set adoRecordset = adoCommand.Execute
Do Until adoRecordset.EOF
	On Error Resume Next
	strTempOutput = &quot;&quot;
	For i = 1 To Ubound(arrAttributes)
		strTempOutput =  strTempOutput &amp; &quot; ; &quot; &amp; adoRecordset.Fields(arrAttributes(i)).Value
		strOutput = Mid(Ltrim(strTempOutput),3)
	Next
	Set objDate = adoRecordset.Fields(arrAttributes(0)).Value
	If (Err.Number &lt;&gt; 0) Then
        dtmDate = #1/1/1601#
    Else
		dtmDate = ((((objDate.Highpart * (2^32)) + objDate.LowPart)/(600000000 - intBias))/1440) + #1/1/1601#
	End If
	Set objDate = Nothing
	Wscript.Echo strOutput &amp; &quot; ; &quot; &amp; dtmDate
	adoRecordset.MoveNext
Loop
adoRecordset.Close
adoConnection.Close
Set adoRecordset = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing

Function TimeZoneBias
	strComputer = &quot;.&quot;
	Set objWMIService = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; &amp; strComputer &amp; &quot;\root\cimv2&quot;)
	Set colTimeZone = objWMIService.ExecQuery(&quot;Select * from Win32_TimeZone&quot;)
	For Each objTimeZone in colTimeZone
		TimeZoneBias = objTimeZone.Bias
	Next
	Set colTimeZone = Nothing
	Set objWMIService = Nothing
End Function
</pre>
<p>When you have problems/questions please post a reply.</p>
<p>Happy scripting.</p>
<p>Best regards,</p>
<p>Dirk Adamsky &#8211; Deludi BV</p>
<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fvbscriptblog.com%2Fvbscript%2Factive-directory%2Flastlogon-active-directory-vbscript%2Factive-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes-v2%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes-v2/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes-v2/"  data-text="Active Directory: VBscript to enumerate the last logon of all AD users and a lot of user attributes V2" data-count="horizontal" data-via="dirkadamsky"></a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes-v2/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes-v2/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Active Directory: VBscript to enumerate the last logon of all AD users and a lot of user attributes</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 15:58:20 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[lastlogon]]></category>
		<category><![CDATA[adsi]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[join]]></category>
		<category><![CDATA[lastlogontimestamp]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[status]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=376</guid>
		<description><![CDATA[! I made a new lastlogonscript, it can be found here. This script is based on the lastlogon script by Richard L. Mueller. Added is an enumeration of 30 user attributes. All in all it gives you an huge load of information&#8230;.. Follow the next steps to run the script (no admin rights needed): * [...]]]></description>
			<content:encoded><![CDATA[<p>! I made a new lastlogonscript, it can be found <a href="http://deludi.nl/blog/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes-v2/">here</a>.<br />
This script is based on the lastlogon script by Richard L. Mueller.<br />
Added is an enumeration of 30 user attributes.<br />
All in all it gives you an huge load of information&#8230;..</p>
<p>Follow the next steps to run the script (no admin rights needed):</p>
<p>* open your favorite text editor<br />
* copy and paste the script into the editor<br />
* save the script (for example c:tempenumerate-lastlogon-details.vbs)<br />
* open a command prompt<br />
* go to &#8220;c:temp&#8221;<br />
* give &#8220;cscript enumerate-lastlogon-details.vbs&#8221; (without quotes) and enter</p>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : enumerate-lastlogon-details.vbs
' Description : script to enumerate the last logon of all AD users and a lot of user attributes
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 25-02-2010
' Level : advanced

Option Explicit

Dim objRootDSE, adoConnection, adoCommand, strQuery, strMail, strDisname, strCompany, strDepartment
Dim adoRecordset, strDNSDomain, objShell, lngBiasKey
Dim lngBias, k, strDN, dtmDate, objDate, arrAttributes
Dim strBase, strFilter, strAttributes, lngHigh, lngLow, strOutput, i

arrAttributes = Array(&quot;cn&quot;,&quot;sAMAccountName&quot;,&quot;company&quot;,&quot;department&quot;,&quot;displayName&quot;,_
				&quot;distinguishedName&quot;,&quot;lastKnownParent&quot;,&quot;mail&quot;,&quot;mailNickname&quot;,&quot;manager&quot;,&quot;physicalDeliveryOfficeName&quot;,_
				&quot;postalCode&quot;,&quot;telephoneNumber&quot;,&quot;userPrincipalName&quot;,&quot;whenChanged&quot;,&quot;whenCreated&quot;,_
				&quot;extensionAttribute1&quot;,&quot;extensionAttribute2&quot;,&quot;extensionAttribute3&quot;,&quot;extensionAttribute4&quot;,&quot;extensionAttribute5&quot;,_
				&quot;extensionAttribute6&quot;,&quot;extensionAttribute7&quot;,&quot;extensionAttribute8&quot;,&quot;extensionAttribute9&quot;,_
				&quot;extensionAttribute10&quot;,&quot;extensionAttribute11&quot;,&quot;extensionAttribute12&quot;,&quot;extensionAttribute13&quot;,_
				&quot;extensionAttribute14,extensionAttribute15,lastLogonTimeStamp&quot;) 

' Obtain local Time Zone bias from machine registry.
Set objShell = CreateObject(&quot;Wscript.Shell&quot;)
lngBiasKey = objShell.RegRead(&quot;HKLMSystemCurrentControlSetControlTimeZoneInformationActiveTimeBias&quot;)
If (UCase(TypeName(lngBiasKey)) = &quot;LONG&quot;) Then
    lngBias = lngBiasKey
ElseIf (UCase(TypeName(lngBiasKey)) = &quot;VARIANT()&quot;) Then
    lngBias = 0
    For k = 0 To UBound(lngBiasKey)
        lngBias = lngBias + (lngBiasKey(k) * 256^k)
    Next
End If
Set objShell = Nothing

' Determine DNS domain from RootDSE object.
Set objRootDSE = GetObject(&quot;LDAP://RootDSE&quot;)
strDNSDomain = objRootDSE.Get(&quot;defaultNamingContext&quot;)
Set objRootDSE = Nothing

' Use ADO to search Active Directory.
Set adoCommand = CreateObject(&quot;ADODB.Command&quot;)
Set adoConnection = CreateObject(&quot;ADODB.Connection&quot;)
adoConnection.Provider = &quot;ADsDSOObject&quot;
adoConnection.Open &quot;Active Directory Provider&quot;
adoCommand.ActiveConnection = adoConnection

' Search entire domain.
strBase = &quot;&lt;LDAP://&quot; &amp; strDNSDomain &amp; &quot;&gt;&quot;

' Filter on all user objects.
strFilter = &quot;(&amp;(objectCategory=person)(objectClass=user))&quot;

' Comma delimited list of attribute values to retrieve.
strAttributes = Join(arrAttributes,&quot;,&quot;)
Wscript.Echo strAttributes
' Construct the LDAP syntax query.
strQuery = strBase &amp; &quot;;&quot; &amp; strFilter &amp; &quot;;&quot; &amp; strAttributes &amp; &quot;;subtree&quot;

' Run the query.
adoCommand.CommandText = strQuery
adoCommand.Properties(&quot;Page Size&quot;) = 100
adoCommand.Properties(&quot;Timeout&quot;) = 60
adoCommand.Properties(&quot;Cache Results&quot;) = False
Set adoRecordset = adoCommand.Execute

' Enumerate resulting recordset.
Do Until adoRecordset.EOF
    On Error Resume Next
    Set objDate = adoRecordset.Fields(&quot;lastLogonTimeStamp&quot;).Value
    If (Err.Number &lt;&gt; 0) Then
        On Error GoTo 0
        dtmDate = #1/1/1601#
    Else
        On Error GoTo 0
        lngHigh = objDate.HighPart
        lngLow = objDate.LowPart
        If (lngLow &lt; 0) Then
            lngHigh = lngHigh + 1
        End If
        If (lngHigh = 0) And (lngLow = 0 ) Then
            dtmDate = #1/1/1601#
        Else
            dtmDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) _
                + lngLow)/600000000 - lngBias)/1440
        End If
    End If
    ' Display values for the user.
    strOutput = &quot;&quot;
	For i = 0 To (Ubound(arrAttributes) - 1)
		strOutput = strOutput &amp; &quot; ; &quot; &amp; adoRecordset.Fields(arrAttributes(i)).Value
	Next
	If (dtmDate = #1/1/1601#) Then
        Wscript.Echo strOutput &amp; &quot; ; Never&quot;
    ElseIf DateDiff(&quot;d&quot;,dtmDate,Date) &gt; 90 Then
	    Wscript.Echo strOutput &amp; &quot; ; &quot; &amp; dtmDate
    End If
    adoRecordset.MoveNext
Loop

' Clean up.
adoRecordset.Close
adoConnection.Close
Set adoRecordset = Nothing
Set objDate = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
</pre>
<p>When you have problems/questions please post a reply.</p>
<p>Happy scripting.</p>
<p>Best regards,</p>
<p>Dirk Adamsky &#8211; Deludi BV</p>
<p>[adrotate group="2" banner="3"] </p>
<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fvbscriptblog.com%2Fvbscript%2Factive-directory%2Flastlogon-active-directory-vbscript%2Factive-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes/"  data-text="Active Directory: VBscript to enumerate the last logon of all AD users and a lot of user attributes" data-count="horizontal" data-via="dirkadamsky"></a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/lastlogon-active-directory-vbscript/active-directory-vbscript-to-enumerate-the-last-logon-of-all-ad-users-and-a-lot-of-user-attributes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

