Re: unlock user accounts en masse
- From: "Richard Mueller [MVP]" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 24 May 2005 21:55:59 -0500
Sam B. wrote:
> I've seen the syntax on unlocking a user account, but is there a way to
> enumerate the list of users in a given container/OU and then incrementally
> unlock the accounts? I've done some digging around and haven't found
pieces
> that I could get to work together.
>
> If it's not possible, I'd like to know that, too.
>
Hi,
Determining if an account is locked out with the LDAP provider is not
simple. I have a sample program to find out if a given user is locked out,
and then allow the user to unlock the account linked here:
http://www.rlmueller.net/IsUserLocked.htm
To check all users in a container/OU, it is actually easier to use the WinNT
provider. For example, here is a sample program to document all accounts
that are locked out:
http://www.rlmueller.net/LockedUsers.htm
The relevant code is:
' Find locked out user accounts in domain.
Set objDomain = GetObject("WinNT://" & strNetBIOSDomain)
objDomain.Filter = Array("user")
For Each objWinNTUser In objDomain
If objWinNTUser.IsAccountLocked = True Then
' Do something.
End If
Next
This could be modified to unlock the accounts. However, because WinNT is
blind to any AD hierarchy, it cannot recognize OU's. I would suggest for
each user found to be locked out to use the NameTranslate object to convert
the NT name (sAMAccountName, which is objWinNTUser.Name above) to the
distinguishedName, and from that determine the parent object (container or
OU).
The NameTranslate object is documented here:
http://www.rlmueller.net/NameTranslateFAQ.htm
Note, the IsAccountLocked method exposed by the LDAP provider does not work.
You might want to use a program that lists all locked out users, then code
another program to read the list and unlock the accounts. This gives you the
opportunity to review the list. I hope this helps.
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab web site - http://www.rlmueller.net
--
.
- References:
- unlock user accounts en masse
- From: Sam B.
- unlock user accounts en masse
- Prev by Date: Invalid syntax on moving users between OUs
- Next by Date: Re: 250 users in an OU. Ineed to know what login scripts they are usin
- Previous by thread: unlock user accounts en masse
- Next by thread: RE: unlock user accounts en masse
- Index(es):
Relevant Pages
|