Title: Set UserAccountControl

Hi,

Is there any possibility of setting both properties?

"Password never expires" and "User must change password at next logon"

I tried with this script, but i can't:

------------------------------
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
m=0

strOU = "cn=test,ou=usuarios,ou=XXXXXXX"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.Properties ("Size Limit")= 1001
objCommand.Properties ("Cache Results")= False
objCommand.Properties("Page Size") = 1001
objCommand.CommandText = _
  "<LDAP://"& strOU &",dc=asp,dc=mundo-r,dc=com>;(objectCategory=user)" & _
  ";distinguishedName,name,mail,ADsPath;subtree"
Set objRecordSet = objCommand.Execute

While Not objRecordSet.EOF
  strADsPath = objRecordset.Fields("ADsPath")
  Set objUser = GetObject(strADsPath)
  objUser.Put "UserAccountControl" , "524288"   ' 0x80000 + 0x10200 = pass never exp + user must change
  objUser.SetInfo
  wscript.echo strADsPath & ";" & objUser.UserAccountControl
  m=m+1
  objRecordSet.MoveNext
Wend

objConnection.Close
wscript.echo "Numero objetos afectados: " &m
------------------------------------------------------------------------------


Thanks,

Moncho





**************************************************************************************************
Este mensaje se dirige exclusivamente a su destinatario. Puede contener
información privilegiada, confidencial o legalmente protegida.
Si ha recibido este mensaje por error le rogamos que lo borre inmediatamente, así como todas sus copias, y lo comunique al remitente.
En virtud de la legislación vigente está prohibida la utilización, divulgación, copia o impresión sin autorización.
No existe renuncia a la confidencialidad o privilegio por causa de una transmisión errónea.
**************************************************************************************************

Reply via email to