[ADSI] - Check If User Acount Is Enabled/Disabled
Not too much explanation needed for this one. :)
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
Re: [ADSI] - Check If User Acount Is Enabled/Disabled
Apparently is only works with NT/Win2000 as I get an automation error on XP Pro.
Re: [ADSI] - Check If User Acount Is Enabled/Disabled
Nope, I tested in on XP Pro SP1. Automation errors are usially an incorrect computer name or user name. Are you running Active Directory?
Re: [ADSI] - Check If User Acount Is Enabled/Disabled
Quote:
Originally Posted by RobDog888
Are you running Active Directory?
:blush: No...nevermind.
Re: [ADSI] - Check If User Acount Is Enabled/Disabled
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.
Re: [ADSI] - Check If User Acount Is Enabled/Disabled
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.