How to programatically read the lockout flag in Windows 2000 and in Windows Server 2003 (250873)
The information in this article applies to:
- Microsoft Windows Server 2003, Enterprise Edition
- Microsoft Windows Server 2003, Standard Edition
- Microsoft Windows 2000 Advanced Server
- Microsoft Windows 2000 Server
This article was previously published under Q250873 SYMPTOMSWhen you are using a program to read and reset the user account lockout bit, your program may never report a user as locked out. The code you are using may look like the following sample script (written in the Visual Basic Scripting Edition).
Set oUser = GetObject("LDAP://cn=locked out user,cn=Users,DC=domain,DC=com")
if oUser.IsAccountLocked then
WScript.Echo "User is locked out"
else
WScript.Echo "User is not locked out"
end if
The userAccountControl property also does not reflect the locked-out status.
CAUSE
The IsAccountLocked property is not accessible by using the Lightweight Directory Access Protocol (LDAP) provider. The lockout flag is not stored in Active Directory, but is created on-the-fly only when you access Active Directory by using the WinNT provider.
RESOLUTION To read or reset the lockout bit, use the WinNT provider to gain access to Active Directory. The following sample VBScript demonstrates this method.
Set oUser = GetObject("WinNT://domainname/username")
if oUser.IsAccountLocked then
WScript.Echo "User is locked out"
else
WScript.Echo "User is not locked out"
end if
The userFlags property has the UF_LOCKOUT bit set as well.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.MORE INFORMATION
User lockout uses the user's lockoutTime property. When you access Active Directory by using the LDAP provider, you can use it to determine the lockout status of the user. If it is larger than zero, the user is currently locked out. To undo the lockout, set the value to zero.
LockoutTime is cleared only when the locked-out user attempts to log on. When the lockout time has expired, but the user has not yet tried to log on, lockoutTime may be still set, although the user would be able to successfully log on at that time.
Modification Type: | Major | Last Reviewed: | 1/17/2006 |
---|
Keywords: | kbprb KB250873 |
---|
|