#93188 - 2003-10-28 07:18 PM
Problem Setting "User must change password at next logon" attribute via ADSI/Kixtart
Everyone
Getting the hang of it
Registered: 2003-10-19
Posts: 81
Loc: Beale Air Force Base, CA
I'm trying to use ADSI code in a Kixtart script, to set accounts so that the user must change the password at next login. Here is an article that shows how to do it in VBScript: Configuring a Password Change at Next Logon Requirement Here is the Kixtart code:code: $Domain = GetObject("LDAP://" + $DN[0]) $Domain.Put "pwdLastSet",0 $Domain.SetInfo This is the error that occurs on the line that says: $Domain.Put "pwdLastSet",0 ERROR : unexpected command! Script: C:\KiX2001.421\test2.kix Line : 40 What do I need to do to make this work? [ 28. October 2003, 19:19: Message edited by: Everyone ]
Top
#93189 - 2003-10-28 07:30 PM
Re: Problem Setting "User must change password at next logon" attribute via ADSI/Kixtart
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
Try...code: $Domain = GetObject("LDAP://" + $DN[0]) $Domain.Put("pwdLastSet",0) $Domain.SetInfo
Top
#93190 - 2003-10-28 07:30 PM
Re: Problem Setting "User must change password at next logon" attribute via ADSI/Kixtart
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Try using parens... $Domain.Put("pwdLastSet",0)
Top
#93195 - 2003-10-28 07:49 PM
Re: Problem Setting "User must change password at next logon" attribute via ADSI/Kixtart
Everyone
Getting the hang of it
Registered: 2003-10-19
Posts: 81
Loc: Beale Air Force Base, CA
quote: Do this then: $ADSUser.Put("PasswordExpired", 1) $ADSUser.SetInfo That gives an "expected expression!" error, unles I change $ADSUser to $Domain. If I change it to $Domain, it does nothing.
Top
#93196 - 2003-10-28 08:01 PM
Re: Problem Setting "User must change password at next logon" attribute via ADSI/Kixtart
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
This code works for me and has been verified via the GUI.$obUser = GetObject ("LDAP://CN=USer,OU=US Pilot Accounts,OU=0001,DC=tyco,DC=com" );
? "Get user: @error @serror"
$obUser.Put ("pwdLastSet" ,0 )
$obUser.SetInfo
? "SetInfo: @error @serror" Are you binding to the same DC with the script as you are with the GUI? [ 28. October 2003, 20:02: Message edited by: Howard Bullock ]
Top
#93197 - 2003-10-28 08:03 PM
Re: Problem Setting "User must change password at next logon" attribute via ADSI/Kixtart
Richie19Rich77
Seasoned Scripter
Registered: 2002-08-16
Posts: 624
Loc: London, England
Hmm, try this then.$STRUserName = "Richard.Farthing"
$STRUSERPATH = "WinNT://@Domain/$STRUserName,User"
$Reset = GetObject ($STRUSERPATH )
$Reset.Put ("PasswordExpired" , 1 )
$Reset.setinfo
[ 28. October 2003, 20:04: Message edited by: Richard Farthing ]
Top
Moderator: Shawn , ShaneEP , Ruud van Velsen , Arend_ , Jochen , Radimus , Glenn Barnas , Allen , Mart
0 registered
and 557 anonymous users online.