Solved

How do I use VBscript to check whether a user is DISABLED

Posted on 2007-03-28
1
2,746 Views
Last Modified: 2008-05-30
How do I use VBscript to check whether a user is DISABLED or not using ADSI / LDAP. I am sure this is quite simply possibe, just cannot get my finger around it. thanks.
0
Comment
Question by:netimpact
1 Comment
 
LVL 70

Accepted Solution

by:
Chris Dent earned 125 total points
ID: 18807686

Hey,

Yep, it's quite simple. This bit of VbScript assumes you know where the user is already and shows both ways:


Const ADS_UF_ACCOUNTDISABLE = &H2

Set objUser = GetObject("LDAP://CN=SomeUser,CN=Users,DC=SomeDomain,DC=com")

intUAC = objUser.Get("userAccountControl")
If intUAC And Not ADS_UF_ACCOUNTDISABLE Then
    WScript.Echo "User is Not Disabled"
End If

If intUAC And ADS_UF_ACCOUNTDISABLE Then
    WScript.Echo "User is Disabled"
End If


HTH

Chris
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now