Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Re: lastLogonTimestamp not set!

Reply
Thread Tools Display Modes

Re: lastLogonTimestamp not set!

 
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      12-27-2008

"Mike" <> wrote in message
news:da43158c-2a08-47b4-b2de-...
> Hello all- I am researching finding old user accounts so they can be
> deleted. I am finding a lot of user accounts have nothing set in the
> lastLogonTimestamp. I've found several conditions that will cause
> this. Of course if the domain is not at Windows Srv 2003 Func Level,
> this will not work, but that is not the case here, we are at the
> highest func level and all DCs are 2003 SP2. Also I found an MS KB
> article that described NTLM auths that would not increment this value,
> but that was supposedly fixed in Srv 2003 SP1 (and we have SP2).
>
> What I want to ask is, does anyone know any other conditions that
> would cause this value to be blank even if the user has logged in and
> is using the account? Some things I can think of are: users who use
> OWA from a public computer, and never log into Windows with the
> account, etc.


When the functional level is first raised, user objects have this attribute
updated randomly over the next 14 days (to avoid too much replication
traffic all at once). After that, the value is updated during logon if the
old value is more than 14 days (by default) in the past. Does that account
for what you see?

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


 
Reply With Quote
 
 
 
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      12-31-2008

"Mike" <> wrote in message
news:56228061-c8ab-4850-bd8e-...
On Dec 26, 10:55 pm, "Richard Mueller [MVP]" <rlmueller-
nos...@ameritech.nospam.net> wrote:
> "Mike" <thelotu...@gmail.com> wrote in message
>
> news:da43158c-2a08-47b4-b2de-...
>
> > Hello all- I am researching finding old user accounts so they can be
> > deleted. I am finding a lot of user accounts have nothing set in the
> > lastLogonTimestamp. I've found several conditions that will cause
> > this. Of course if the domain is not at Windows Srv 2003 Func Level,
> > this will not work, but that is not the case here, we are at the
> > highest func level and all DCs are 2003 SP2. Also I found an MS KB
> > article that described NTLM auths that would not increment this value,
> > but that was supposedly fixed in Srv 2003 SP1 (and we have SP2).

>
> > What I want to ask is, does anyone know any other conditions that
> > would cause this value to be blank even if the user has logged in and
> > is using the account? Some things I can think of are: users who use
> > OWA from a public computer, and never log into Windows with the
> > account, etc.

>
> When the functional level is first raised, user objects have this
> attribute
> updated randomly over the next 14 days (to avoid too much replication
> traffic all at once). After that, the value is updated during logon if the
> old value is more than 14 days (by default) in the past. Does that account
> for what you see?
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab -http://www.rlmueller.net
> --


Hi Richard- thanks for your reply. The domain has been at this
functional level for the past year at least, so I don't think the 14
day replication delay would explain this. So from what I can tell
here, if the lastLogonTimestamp is blank, then this would indicate
that these users have never logged in. This is quite possible, many of
the accounts I have spot-checked have never set their password at
first logon.

Can I ask you a separate question. I am a bit new to vbscript and am
using your script from 'http://www.rlmueller.net/Programs/
LastLogonTimeStamp.txt' and it works great, thanks. I want to add some
fields to the output so I can do some more sleuthing on these
accounts. I tried to add displayName as a test as show below, but got
the error you see at the end. Can you advise me how can I ad fields to
the resulting query so I have more information to work with? I'd like
to get a few different fields: userAccountControl, pwdLastSet,
homeMDB, and expirationTime.

Dim lngBias, k, strDN, strDisplayName, dtmDate, objDate

' Enumerate resulting recordset.
Do Until adoRecordset.EOF
' Retrieve attribute values for the user.
strDN = adoRecordset.Fields("distinguishedName").Value
strDisplayName = adoRecordset.Fields("displayName").Value

c:\LastLogonTimeStamp.vbs (80, 5) ADODB.Recordset: Item cannot be
found in the collection corresponding to the requested name or
ordinal.

-----------------------------

Add the attribute names to the comma delimited list of attributes to be
retrieved. For example:
==========
' Comma delimited list of attribute values to retrieve.
strAttributes = "distinguishedName,lastLogonTimeStamp,displayN ame"
=======
You can add all attribute LDAP names you want to retrieve. For
userAccountControl you can display the integer value, but you must test with
a bit mask to determine which bits are set, and thus which settings apply.
For example:
========
' Define bit mask for "Account Disabled".
Const ADS_UF_ACCOUNTDISABLE = &H02

lngFlag = CLng(adoRecordset.Fields("userAccountControl").Val ue)

If (lngFlag And ADS_UF_ACCOUNTDISABLE) <> 0 Then
Wscript.Echo "Account is disabled"
Else
Wscript.Echo "Account is NOT disabled"
End If
=====
You use the And operator and a bit mask to test each setting. See the link
below for more bit masks. Any non-zero result means the bit is set, a zero
result means the bit is not set. The pwdLastSet attribute is Integer8, just
like lastLogonTimeStamp, so you must use the same technique to convert the
64-bit value to a date/time in the current time zone. There is no
expirationTime attribute, but there is an accountExpires attribute, another
Integer8. This example VBScript program demonstrates how to handle Integer8
attributes and userAccountControl using functions (user defined functions
GetFlags and Integer8Date):

http://www.rlmueller.net/DocumentUsers.htm

This program might be a better starting point for what you are trying to do.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LastLogonTimeStamp Lamborghini Scripting 3 11-26-2008 08:14 PM
lastlogontimestamp Yogesh Malhotra Active Directory 1 09-10-2008 02:49 PM
Lastlogontimestamp Gustavo Scripting 1 04-07-2008 04:11 PM
Re: LastLogonTimeStamp Al Dunbar [MS-MVP] Scripting 1 01-26-2007 05:52 PM
lastLogonTimestamp Chris Active Directory 9 05-18-2006 02:17 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59