Hi guys and gals!
Not sure if this question belongs here, but I would ask it anyway.
I am using ADSI to find out the last login information for my windows users. However, I am getting the wrong value. Can anyone help me out here?
See below for my code.
Code:
<TABLE BORDER="1" CELLSPACING="0">
<TR bgcolor="#C0C0C0">
<TD><b>Username</b></TD>
<TD><b>Name</b></TD>
<TD><b>Description</b></TD>
<TD><b>Last Login</b></TD>
<TD><b>Days</b></TD>
<TD><b>Password Expiration</b></TD>
<TD><b>Disabled</b></TD>
</TR>
<%
Dim today, clock, both, numberofdays 'Dim is a keyword to declare variables like var for javascript
today = Date 'Date is a built in VBScript function that returns the current Date
clock = Time ' Time is a built in VBScript function that returns the current Time
both = Now ' Now is a built in VBScript function that returns both the Date and the Time
numberofdays = Request.Form("numdays")
Dim sUserInfo
On Error Resume Next
Set oContainer = GetObject("WinNT://Domain name/computername")
For Each oIADs In oContainer
If (oIADs.Class = "User") Then
Set oUser = oIADs
UserName = ""
FullName = ""
Descripcion = ""
LastLogin = ""
PasswordExpiration = ""
Disabled = ""
UserName = oUser.Name
FullName = oUser.FullName
Descripcion = oUser.Description
LastLogin = oUser.LastLogin
PasswordExpiration = oUser.PasswordExpirationDate
Disabled = oUser.AccountDisabled
Days = dateDiff("d",oUser.LastLogin,today)
%>
<TR>
<TD><%=UserName%> </TD>
<TD><%=FullName%> </TD>
<TD><%=Descripcion%> </TD>
<TD><%=LastLogin%> </TD>
<TD><%=Days%> </TD>
<TD><%=PasswordExpiration%> </TD>
<TD><%=Disabled%> </TD>
<% End If%>
<%Next%>
</TABLE>
I have tried the PDC and BDC computer names, but they reflect differing values. Can anyone help?
Would it make a difference if I coded this in
VB?
Thanks! =)
YWT