Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 5th, 2004, 09:30 PM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default ADSI problem

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
__________________
YWT
 
Old January 8th, 2004, 03:41 AM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is there anyone who can help me out here?

YWT
 
Old January 8th, 2004, 04:36 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

Do you get an error message if you comment out On Error Resume Next?
Which value is wrong?
 
Old January 8th, 2004, 08:43 PM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hmmmm ... Strangely. It gives me the following error message.

-------
Active Directory (0x8000500D)
The directory property cannot be found in the cache.
-------

I uncommented the "On Error Resume Next and the LastLogin property value is correct and wrong for some. But basically, I cannot use wrong values for this. Anywayz, I tried using VB for this. The result is the same. I get some correct results and I get some wrong results.

Is there any way to resolve this?

Please help. Thanks!

YWT
 
Old January 16th, 2004, 02:59 AM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I will answer my own question then.

The reason for this is that the BDC and PDC have different last login values. Thus, some results and incorrect and some are correct. You would need to compare the lastlogin with the BDC and PDC and capture the latest reading between them and choose to display it.

I suggest that you use VBS to do this rather than ASP. This is because it can be quite time consuming, depending on your number of users.

YWT
 
Old February 24th, 2004, 03:51 PM
Registered User
 
Join Date: Feb 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,

This may mean that the user you created did never logged on to the system.

Try changing password by .ChangePassword method, and use LastLogin property.

Txs.

http://www.aliayen.com (Turkish)





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get certain ADSI Attributes grassi3000 C# 0 August 31st, 2004 12:03 PM
ADSI mikedeepak Classic ASP Professional 1 August 13th, 2004 06:33 PM
Active Directory (ADSI) C# Group Info LDAP Problem ro C# 0 June 23rd, 2004 01:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.