Richard
Fri Oct 31 20:28:14 CST 2003
Jim Campau wrote:
> I have the following vbscript that returns the user's last logon.
> Can it be modifyed to return the Computer's last logon?
>
> Thanks in advance.
>
> ==================================
>
> Dim User
> user = InputBox("Enter user ID","Last Logon")
>
> 'msgbox user
>
> Set wshArguments = WScript.Arguments
> set objUser = GetObject("LDAP://" & "CN=" & User &
> ",OU=USERS,OU=TPA,OU=USA,DC=domain,DC=com")
>
>
> str1 = "Last Login: " & objUser.LastLogin
>
> MsgBox str1
>
>
Hi,
As written, the program will work for computer objects, assuming the
computer objects are in the "ou=User" container, and you supply the cn
(common name) of a computer.
The LastLogin property method returns the date stored on the nearest Domain
Controller. Since a different date is stored on each DC, this might not be
the value you want. A more sophisticated program that returns the last logon
date for all users in the domain is at this link:
http://www.rlmueller.net/Last%20Logon.htm
The program can be modifed to return the last logon date for all computer
objects by replacing the statement:
strFilter = "(&(objectCategory=person)(objectClass=user))"
with the statement
strFilter = "(objectCategory=computer)"
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site -
http://www.rlmueller.net
--