Re: password never expires
From: Chriss3 (noSpamHere_at_chrisse.se)
Date: 06/01/04
- Next message: CD: "Re: AD admin tools on WinXP"
- Previous message: SJ99: "Bug check 0xA7"
- In reply to: Aone: "Re: password never expires"
- Next in thread: Aone: "Re: password never expires"
- Reply: Aone: "Re: password never expires"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 1 Jun 2004 20:23:58 +0200
Configures a user account so that it will not expire. This is done by
setting the expiration date to 1/1/1970.
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strBase = "<LDAP://ou=sales,dc=ladava,dc=com>"
strFilter =
";(&(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113
556.1.4.803:=65536))"
strAttributes = ";sAMAccountName,ADsPath"
strLevel = ";subtree"
objCommand.CommandText = strBase & strFilter & strAttributes & strLevel
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("sAMAccountName")
Set objUser = GetObject(objRecordSet.Fields("ADsPath"))
intUAC = objUser.Get("userAccountControl")
objUser.Put "userAccountControl", intUAC XOR ADS_UF_DONT_EXPIRE_PASSWD
objUser.AccountExpirationDate = "01/01/1970"
objUSer.SetInfo
objRecordSet.MoveNext
Loop
objConnection.Close
Set objRootDSE = Nothing
Set objCommand = Nothing
Set objConnection = Nothing
Set objRecordSet = Nothing
User cannot change password is more advanced i think you have to change the
NTSecurityDescriptor then, i leave that to Matjaz, Password never expires
should be fine.
-- Regards Christoffer Andersson No email replies please - reply in the newsgroup ------------------------------------------------ http://www.chrisse.se - Active Directory Tips "Aone" <anonymous@discussions.microsoft.com> skrev i meddelandet news:57D94173-AE16-41B3-B978-1CE08243DC55@microsoft.com... > Thanks Matjaz, > The script is working fine! > > In my requirement i need to uncheck both the > 1) "user cannot change password" > 2) "Password never expires" checkboxes. > > How to include this modification in the same script or in seperate script.
- Next message: CD: "Re: AD admin tools on WinXP"
- Previous message: SJ99: "Bug check 0xA7"
- In reply to: Aone: "Re: password never expires"
- Next in thread: Aone: "Re: password never expires"
- Reply: Aone: "Re: password never expires"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|