Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

List User Domains using GetObject

0.00/5 (No votes)
25 Apr 2002 1  
How to list or manage users from a domain

Introduction

This article gives you some code to list or manage users from a domain using GetObject

<TABLE BORDER="1" CELLSPACING="0">
<TR>
    <TD>Username</TD>
    <TD>Name</TD>
    <TD>Description</TD>
    <TD>Last Login</TD>
    <TD>Password Expiration</TD>
    <TD>Disabled</TD>
</TR>
<%

Dim sUserInfo

On Error Resume Next

Set oContainer = GetObject("WinNT://Domain_Name")

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 
%>

<TR>
    <TD><%=UserName%> </TD>
    <TD><%=FullName%> </TD>
    <TD><%=Descripcion%> </TD>
    <TD><%=LastLogin%> </TD>
    <TD><%=PasswordExpiration%> </TD>
    <TD><%=Disabled%> </TD>
<%    End If%>    
<%Next%>
</TABLE>

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here