Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Set colAccounts = GetObject("WinNT://" & strComputer & "")
colAccounts.Filter = Array("user")
For Each objUser In colAccounts
Wscript.Echo objUser.Name objUserFlags = objUser.Get("UserFlags")
objPasswordExpirationFlag = objUserFlags OR ADS_UF_DONT_EXPIRE_PASSWD
objUser.Put "userFlags", objPasswordExpirationFlag
objUser.SetInfo
Next
Thursday, October 27, 2005
Sunday, October 23, 2005
Set AD user password to non-expiry
using System.DirectoryServices;using ActiveDs;
//Add reference to COM Active DS TypeLib
static void DontExpirePassword(DirectoryEntry User)
{
int val;
const int ADS_UF_DONT_EXPIRE_PASSWD =0x10000;
val = (int) User.Properties["userAccountControl"].Value;
User.Properties["userAccountControl"].Value = val ADS_UF_DONT_EXPIRE_PASSWD;
User.CommitChanges();
}
//Add reference to COM Active DS TypeLib
static void DontExpirePassword(DirectoryEntry User)
{
int val;
const int ADS_UF_DONT_EXPIRE_PASSWD =0x10000;
val = (int) User.Properties["userAccountControl"].Value;
User.Properties["userAccountControl"].Value = val ADS_UF_DONT_EXPIRE_PASSWD;
User.CommitChanges();
}
Labels:
Code
Subscribe to:
Posts (Atom)