# VBForums CodeBank > CodeBank - Other >  [ADSI] - Check If User Acount Is Enabled/Disabled

## RobDog888

Not too much explanation needed for this one.  :Smilie: 

VB Code:
Option Explicit
 Private Sub Command1_Click()
    Dim oUser As Object
    Set oUser = GetObject("WinNT://ComputerName/UserName")
    If oUser.AccountDisabled = True Then
        MsgBox oUser.Name & " Disabled!"
    Else
        MsgBox oUser.Name & " Enabled!"
    End If
    Set oUser = Nothing
End Sub

----------


## Hack

Apparently is only works with NT/Win2000 as I get an automation error on XP Pro.

----------


## RobDog888

Nope, I tested in on XP Pro SP1. Automation errors are usially an incorrect computer name or user name. Are you running Active Directory?

----------


## Hack

> Are you running Active Directory?


  :Blush:   No...nevermind.

----------


## RobDog888

Hmm, seems that using NTDS or ADSI makes no difference. The format of the code is the same. I tested it on my XP system which is not part of my domain that is running AD nor my user account. Still worked.

----------


## knightcon

It doesn't matter if your computer is running ad or not. As long as it has a network or internet connection to the computer which does run it, even if your computer doesn't use it, it can still get information from it and query it. All that is needed is a computer name/domain name, and the username you want to query.

----------

