Re: instituting ad password policy
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 9 Apr 2007 15:30:33 -0500
"Danny Sanders" <DSanders@xxxxxxxxxxxxxxx> wrote in message
news:e6z4J0teHHA.5052@xxxxxxxxxxxxxxxxxxxxxxx
However you implement the password policy the user disruption will be the
same.
. Disable the password never expires option
Either script this or do it manually. Users will not notice this.
A script I have used to remove the "password never expires" setting for all
users:
=================
Option Explicit
Dim objRootDSE, strDNSDomain, adoCommand, adoConnection
Dim strBase, strFilter, strAttributes, strQuery, adoRecordset
Dim strDN, objUser, lngFlag
Const ADS_UF_DONT_EXPIRE_PASSWD = &H10000
' Determine DNS domain name.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
' Use ADO to search Active Directory.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
' Search all of Active Directory.
strBase = "<LDAP://" & strDNSDomain & ">"
' Filter on user objects that have password never expires flag set.
strFilter = "(&(objectCategory=person)(objectClass=user)" _
& "(userAccountControl:1.2.840.113556.1.4.803:=65536))"
' Comma delimited list of attribute values to retrieve.
strAttributes = "distinguishedName"
' Query Active Directory and return recordset.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
Set adoRecordset = adoCommand.Execute
' Enumerate the recordset.
Do Until adoRecordset.EOF
' Retrieve the attribute value.
strDN = adoRecordset.Fields("distinguishedName")
' Bind to the corresponding user object.
Set objUser = GetObject("LDAP://" & strDN)
' Retrieve flags.
lngFlag = objUser.userAccountControl
' Toggle the bit for password never expires to turn it off.
lngFlag = lngFlag Xor ADS_UF_DONT_EXPIRE_PASSWD
' Save the new value.
objUser.userAccountControl = lngFlag
' Save the change.
objUser.SetInfo
adoRecordset.MoveNext
Loop
' Clean up.
adoRecordset.Close
adoConnection.Close
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
.
- References:
- Re: instituting ad password policy
- From: Danny Sanders
- Re: instituting ad password policy
- Prev by Date: how to setup site so that exchange 2003 communicates only with windows 2003 global catalog
- Next by Date: Re: Delegate Account reset not working...
- Previous by thread: Re: instituting ad password policy
- Next by thread: Re: instituting ad password policy
- Index(es):
Relevant Pages
|
Loading