Introduction to System.DirectoryServices, Part 2
Subject:   Determine disabled account
Date:   2008-06-30 23:24:53
From:   TFX77
Using NativeObject is not always prefferable.

First the code is late binding for faster and more readalbe code so with

Option Strict On

it's impossible to use.

Second it's easier to find disabled users via the LDAP query.

For instance:


This will find ALL disabled users in the OU your'e searching. 514 (disabled)/546 (disabled, no passwd req.)/66050 (disabled, passwd never exp.)

A non LDAP query method for disabled/enabled users I wrote using the LDAP bitwise method is:

Get the userAccountControl as an integer.

Dim intValue As Integer = CInt(dirUserProperties.Properties("userAccountControl").Value)

Cbool the integer "And" (for disabled) or "And Not" (for enabled) with hexidecimal &H2.


Greetings from the Netherlands,