G
Guest
Hi
I need to remove the password never expires property on my users accounts, I
have tried dsmod but can only do one user at a time, not a complete ou. I
have seent the attached script that was previoulsy posted on here, but I do
not have a clue how to run it, could anyone please help me!
Thank you so much in advance.
Pauline
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.113556.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.SetInfo
objRecordSet.MoveNext
Loop
objConnection.Close
Set objRootDSE = Nothing
Set objCommand = Nothing
Set objConnection = Nothing
Set objRecordSet = Nothing
I need to remove the password never expires property on my users accounts, I
have tried dsmod but can only do one user at a time, not a complete ou. I
have seent the attached script that was previoulsy posted on here, but I do
not have a clue how to run it, could anyone please help me!
Thank you so much in advance.
Pauline
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.113556.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.SetInfo
objRecordSet.MoveNext
Loop
objConnection.Close
Set objRootDSE = Nothing
Set objCommand = Nothing
Set objConnection = Nothing
Set objRecordSet = Nothing