Ari wrote:
> Thanks for the response
> do you know where i can find a script for that i dont know how to make the
> script..
If you have Windows Server 2003, you may be able to select all users and
modify this setting in bulk. Otherwise, here is a VBScript program that uses
ADO to retrieve all user objects were the flag "Password never expires" is
set, then toggles this flag off for each of these users, and saves the
change. Since ADO cannot be used to modify AD objects, we retrieve the
Distinguished Names of the user, so we can bind to the corresponding
objects. A bit of the userAccountControl attribute is the flag for this
setting. We Xor with the appropriate bit mask to toggle the setting off.
===============
Option Explicit
Dim objRootDSE, strDNSDomain, objCommand, objConnection
Dim strBase, strFilter, strAttributes, strQuery, objRecordSet
Dim strDN, lngPwdLastSet, objDate
Dim 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 objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
' 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"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
' Enumerate the recordset.
Do Until objRecordSet.EOF
' Retrieve the attribute value.
strDN = objRecordSet.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
objRecordSet.MoveNext
Loop
' Clean up.
objConnection.Close
Set objRootDSE = Nothing
Set objCommand = Nothing
Set objConnection = Nothing
Set objRecordSet = Nothing
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab -
http://www.rlmueller.net