#166428 - 2006-08-25 05:55 PM
ADSI enable reset user acct KixForm
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
Code:
$DefPWD = "12345678"
$_=SetConsole('Hide')
Break On $System = CreateObject("Kixtart.System")
;KD START
;************* Form ************** $Form = $System.Form() $Form.BackColor = 212,208,200 $Form.FormBorderStyle = 3 $Form.Height = 230 $Form.MaximizeBox = "False" $Form.Text = "Reset User Account" $Form.Width = 432 ;**************************************
;************* UseridLabel ************** $UseridLabel = $Form.Controls.Label("UserID:", 10, 18, 50, 17) $UseridLabel.BackColor = 212,208,200 ;**************************************
;************* UserIDTextBox ************** $UserIDTextBox = $Form.Controls.TextBox("", 65, 15, 146, 20) $UserIDTextBox.OnKeyDown = "EnterUser()" ;**************************************
;************* UserNameTextBox ************** $UserNameTextBox = $Form.Controls.TextBox("", 65, 45, 351, 48) $UserNameTextBox.BorderStyle = 1 $UserNameTextBox.Multiline = "True" $UserNameTextBox.ReadOnly = "True" ;**************************************
;************* AcctLockedCheckBox ************** $AcctLockedCheckBox = $Form.Controls.CheckBox("", 105, 120, 20, 21) $AcctLockedCheckBox.BackColor = 212,208,200 $AcctLockedCheckBox.CheckAlign = 16 $AcctLockedCheckBox.Enabled = "False" $AcctLockedCheckBox.TabStop = "False" ;**************************************
;************* DisabledCheckBox ************** $DisabledCheckBox = $Form.Controls.CheckBox("", 210, 120, 20, 20) $DisabledCheckBox.BackColor = 212,208,200 $DisabledCheckBox.CheckAlign = 16 $DisabledCheckBox.Enabled = "False" ;**************************************
;************* PassExpiredCheckBox ************** $PassExpiredCheckBox = $Form.Controls.CheckBox("", 350, 120, 20, 20) $PassExpiredCheckBox.BackColor = 212,208,200 $PassExpiredCheckBox.CheckAlign = 16 $PassExpiredCheckBox.Enabled = "False" $PassExpiredCheckBox.TabStop = "False" ;**************************************
;************* UnlockButton ************** $UnlockButton = $Form.Controls.Button("Unlock/Enable Account", 65, 165, 214, 22) $UnlockButton.TabStop = "False" $UnlockButton.OnClick = "Unlock()" ;**************************************
;************* ResetButton ************** $ResetButton = $Form.Controls.Button("Reset Password", 300, 165, 115, 22) $ResetButton.TabStop = "False" $ResetButton.OnClick = "ResetPassword()" ;**************************************
;************* Label2 ************** $Label2 = $Form.Controls.Label("Account Locked", 65, 105, 88, 17) $Label2.BackColor = 212,208,200 ;**************************************
;************* Label3 ************** $Label3 = $Form.Controls.Label("Account Disabled", 180, 105, 94, 17) $Label3.BackColor = 212,208,200 ;**************************************
;************* Label4 ************** $Label4 = $Form.Controls.Label("Must Change PW", 315, 105, 98, 16) $Label4.BackColor = 212,208,200 ;**************************************
;************* ClearButton ************** $ClearButton = $Form.Controls.Button("Clear", 365, 15, 49, 21) $ClearButton.OnClick = "Clear()" ;**************************************
;************* Label5 ************** $Label5 = $Form.Controls.Label("Account Details", 10, 53, 50, 32) $Label5.BackColor = 212,208,200 ;**************************************
;************* Label6 ************** $Label6 = $Form.Controls.Label("Default PW: "+$DefPWD, 320, 188, 90, 10) $Label6.BackColor = 212,208,200 $Label6.FontSize = 6 ;**************************************
;KD END
$userobj = 0
$Form.Show $UserIDTextBox.SetFocus() While $Form.Visible $=Execute($Form.DoEvents()) Loop Exit 1
Function EnterUser() If $UserIDTextBox.KeyCode=13 $userobj = 0 GetUser() EndIf EndFunction
Function Getuser() $userobj = getobject("WinNT://@LDOMAIN/"+$UserIDTextBox.text+",user") if $userobj $UserNameTextBox.Text = $userobj.FullName +" connected" + @crlf + "Last Logon: "+ $userobj.LastLogin + @crlf + "Password Expiration date: "+ $userobj.PasswordExpirationDate + @crlf + " " $AcctLockedCheckBox.Checked = $UserObj.IsAccountLocked $DisabledCheckBox.Checked = $UserObj.AccountDisabled $PassExpiredCheckBox.Checked = $UserObj.PasswordExpired else $UserNameTextBox.Text = $UserIDTextBox.text +" account not found" endif endfunction
Function Unlock() if $UserObj $SI = 0 if $UserObj.IsAccountLocked $UserObj.IsAccountLocked = 0 $SI = 1 endif if $UserObj.AccountDisabled $UserObj.AccountDisabled = 0 $SI = 1 endif if $SI = 1 $userobj.SetInfo endif GetUser() endif EndFunction
Function ResetPassword() if $UserObj $UserObj.PasswordExpired = 1 $userobj.setPassword($DefPWD) $userobj.SetInfo GetUser() endif Endfunction
Function Clear() $userobj = 0 $UserNameTextBox.text = '' $UserIDTextBox.text = '' $AcctLockedCheckBox.Checked = 0 $DisabledCheckBox.Checked = 0 $PassExpiredCheckBox.Checked = 0 endfunction
updated to include suggestion for setfocus added easy location for changing default PW
Edited by Radimus (2006-08-28 02:24 PM)
|
Top
|
|
|
|
#166429 - 2006-08-26 01:45 AM
Re: ADSI enable reset user acct KixForm
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
|
Top
|
|
|
|
#166435 - 2006-08-29 11:14 PM
Re: ADSI enable reset user acct KixForm
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
nevermind, I made one...
Code:
global $arrNames[0]
Break On $System = CreateObject("Kixtart.System")
;KD START
;************* Form ************** $ADForm = $System.Form() $ADForm.FormBorderStyle = 3 $ADForm.Height = 435 $ADForm.MaximizeBox = "False" $ADForm.MinimizeBox = "False" $ADForm.Text = "" $ADForm.Width = 195 ;**************************************
;************* TextBox1 ************** $TextBox1 = $ADForm.Controls.TextBox("", 5, 5, 175, 20) $TextBox1.OnKeyDown = "FindUser()" ;**************************************
;************* ListBox1 ************** $ListBox1 = $ADForm.Controls.ListBox("", 5, 35, 175, 330) $listBox1.Sorted = "True" $listBox1.OnClick = "ListBoxClicked" $listBox1.OnDoubleClick = "ListBoxdblClicked" ;**************************************
;************* TextBox2 ************** $TextBox2 = $ADForm.Controls.TextBox("", 5, 375, 175, 20) $TextBox2.BackColor = 212,208,200 $TextBox2.BorderStyle = 0 $TextBox2.ReadOnly = "True" $TextBox2.TabStop = "False" ;**************************************
;************* ProgForm ************** $ProgForm = $System.Form() $ProgForm.FormBorderStyle = 0 $ProgForm.Height = 60 $ProgForm.StartPosition = 4 $ProgForm.Text = "" $ProgForm.TopMost = "True" $ProgForm.Width = 300 ;**************************************
;************* PBar1 ************** $PBar1 = $ProgForm.Controls.ProgressBar("PBar1", 15, 30, 267, 11) ;**************************************
;************* Label1 ************** $Label1 = $ProgForm.Controls.Label("Searching AD for Usernames", 60, 10, 170, 16)
;KD END
$ADForm.Show LoadListBox() $TextBox1.SetFocus()
While $ADForm.Visible $=Execute($ADForm.DoEvents()) Loop Exit 1
;**********************************************************************************************************************
Function LoadListBox() if ubound($arrNames) < 1 $ProgForm.Show $ldap="LDAP://"+@domain+"/"+GetObject("LDAP://rootDSE").Get("defaultNamingContext") $ou = EnumOUs($ldap, 'user') $ProgForm.Hide
redim $arrNames[$ListBox1.ListCount] for $element=0 to $ListBox1.ListCount - 1 $ListBox1.ListIndex = $element $arrNames[$element] = $ListBox1.Text next else $ListBox1.List = $arrNames $listbox1.removeitem(0) endif $ListBox1.listindex = 0 EndFunction
Function ListBoxClicked() $TextBox1.text = $ListBox1.Text EndFunction
Function ListBoxdblClicked() ; insert selection action below ; ? $ListBox1.Text ; ; $listbox1.clear loadlistbox() $TextBox1.text = '' EndFunction
Function Finduser() if $TextBox1.KeyCode=13 ; insert selection action below ; ? $ListBox1.Text ; ; $listbox1.clear loadlistbox() $TextBox1.text = '' else for $element=0 to $ListBox1.ListCount - 1 if left($ListBox1.List($element),len($TextBox1.text))=$TextBox1.text $ListBox1.ListIndex = $element $element = $ListBox1.ListCount endif next endif EndFunction
Function EnumOUs($LDAP, $Filter) dim $aFilter[0], $pos, $objOU, $i, $j
if $Filter <> 'user' $Filter = 'computer' endif $objOU = GetObject($LDAP) if VarTypeName($objOU)='Object' $aFilter[0] = $Filter $objOU.Filter = $aFilter for each $item in $objOU $PBar1.Value = iif($PBar1.Value < $PBar1.Max,$PBar1.Value + 1,0) ;for progress bar only if $item.class = $Filter $ListBox1.AddItem($item.sAMAccountName) $TextBox2.text = '' + $ListBox1.ListCount + ' Items found' $i = $LDAP endif next $aFilter[0] = "organizationalUnit" $objOU.Filter = $aFilter for each $item in $objOU $PBar1.Value = iif($PBar1.Value < $PBar1.Max,$PBar1.Value + 1,0) ;for progress bar only $Name = $item.Name $pos = instrrev($LDAP,"/") $DN = Left($LDAP,$pos) + $Name + ", " + substr($LDAP, $pos+1) $j = EnumOUs($DN, $Filter) if $j $i = iif($i,$i +"|"+ $j,$j) endif next endif $EnumOUs = $i Endfunction
|
Top
|
|
|
|
#166438 - 2006-08-30 02:36 AM
Re: ADSI enable reset user acct KixForm
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
Rad, This is great! I am glad to see some KiXforms, and this is great tool. Thanks for posting it over at kforg too, not enough traffic over there and this should help to get things flowing.
|
Top
|
|
|
|
#166439 - 2006-08-30 03:17 AM
Re: ADSI enable reset user acct KixForm
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
Code:
$UserNameTextBox.Text = $userobj.FullName +" connected" + @crlf + "Last Logon: "+ $userobj.LastLogin + @crlf + "Password Expiration date: "+ $userobj.PasswordExpirationDate + @crlf +
|
Top
|
|
|
|
#166440 - 2006-08-30 03:18 AM
Re: ADSI enable reset user acct KixForm
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
Quote:
Rad, This is great! I am glad to see some KiXforms, and this is great tool. Thanks for posting it over at kforg too, not enough traffic over there and this should help to get things flowing.
It is much better now that files can be uploaded.
Glad to do it.
|
Top
|
|
|
|
#166441 - 2006-08-30 06:37 PM
Re: ADSI enable reset user acct KixForm
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
Code:
$DefPWD = "12345678"
$userobj = 0 global $arrNames[0]
;$_=SetConsole('Hide') Break On $System = CreateObject("Kixtart.System")
;KD START
;************* Form ************** $Form = $System.Form() $Form.BackColor = 212,208,200 $Form.FormBorderStyle = 3 $Form.Height = 230 $Form.MaximizeBox = "False" $Form.Text = "Reset User Account" $Form.Width = 432 ;**************************************
;************* UseridLabel ************** $UseridLabel = $Form.Controls.Label("UserID:", 10, 18, 50, 17) $UseridLabel.BackColor = 212,208,200 ;**************************************
;************* UserIDTextBox ************** $UserIDTextBox = $Form.Controls.TextBox("", 65, 15, 146, 20) $UserIDTextBox.OnKeyDown = "EnterUser()" ;**************************************
;************* UserNameTextBox ************** $UserNameTextBox = $Form.Controls.TextBox("", 65, 45, 351, 48) $UserNameTextBox.BorderStyle = 1 $UserNameTextBox.Multiline = "True" $UserNameTextBox.ReadOnly = "True" ;**************************************
;************* AcctLockedCheckBox ************** $AcctLockedCheckBox = $Form.Controls.CheckBox("", 105, 120, 20, 21) $AcctLockedCheckBox.BackColor = 212,208,200 $AcctLockedCheckBox.CheckAlign = 16 $AcctLockedCheckBox.Enabled = "False" $AcctLockedCheckBox.TabStop = "False" ;**************************************
;************* DisabledCheckBox ************** $DisabledCheckBox = $Form.Controls.CheckBox("", 210, 120, 20, 20) $DisabledCheckBox.BackColor = 212,208,200 $DisabledCheckBox.CheckAlign = 16 $DisabledCheckBox.Enabled = "False" ;**************************************
;************* PassExpiredCheckBox ************** $PassExpiredCheckBox = $Form.Controls.CheckBox("", 350, 120, 20, 20) $PassExpiredCheckBox.BackColor = 212,208,200 $PassExpiredCheckBox.CheckAlign = 16 $PassExpiredCheckBox.Enabled = "False" $PassExpiredCheckBox.TabStop = "False" ;**************************************
;************* UnlockButton ************** $UnlockButton = $Form.Controls.Button("Unlock/Enable Account", 65, 165, 214, 22) $UnlockButton.TabStop = "False" $UnlockButton.OnClick = "Unlock()" ;**************************************
;************* ResetButton ************** $ResetButton = $Form.Controls.Button("Reset Password", 300, 165, 115, 22) $ResetButton.TabStop = "False" $ResetButton.OnClick = "ResetPassword()" ;**************************************
;************* Label2 ************** $Label2 = $Form.Controls.Label("Account Locked", 65, 105, 88, 17) $Label2.BackColor = 212,208,200 ;**************************************
;************* Label3 ************** $Label3 = $Form.Controls.Label("Account Disabled", 180, 105, 94, 17) $Label3.BackColor = 212,208,200 ;**************************************
;************* Label4 ************** $Label4 = $Form.Controls.Label("Must Change PW", 315, 105, 98, 16) $Label4.BackColor = 212,208,200 ;**************************************
;************* FindButton ************** $FindButton = $Form.Controls.Button("Find", 300, 15, 49, 21) $FindButton.OnClick = "Find()" ;**************************************
;************* ClearButton ************** $ClearButton = $Form.Controls.Button("Clear", 365, 15, 49, 21) $ClearButton.OnClick = "Clear()" ;**************************************
;************* Label5 ************** $Label5 = $Form.Controls.Label("Account Details", 10, 53, 50, 32) $Label5.BackColor = 212,208,200 ;**************************************
;************* Label6 ************** $Label6 = $Form.Controls.Label("Default PW: "+$DefPWD, 320, 188, 90, 10) $Label6.BackColor = 212,208,200 $Label6.FontSize = 6 ;**************************************
;************* Form ************** $ADForm = $System.Form() $ADForm.FormBorderStyle = 3 $ADForm.Height = 435 $ADForm.MaximizeBox = "False" $ADForm.MinimizeBox = "False" $ADForm.Text = "" $ADForm.Width = 195 ;**************************************
;************* TextBox1 ************** $TextBox1 = $ADForm.Controls.TextBox("", 5, 5, 175, 20) $TextBox1.OnKeyDown = "FindUser()" ;**************************************
;************* ListBox1 ************** $ListBox1 = $ADForm.Controls.ListBox("", 5, 35, 175, 330) $listBox1.Sorted = "True" $listBox1.OnClick = "ListBoxClicked" $listBox1.OnDoubleClick = "ListBoxdblClicked" ;**************************************
;************* TextBox2 ************** $TextBox2 = $ADForm.Controls.TextBox("", 5, 375, 175, 20) $TextBox2.BackColor = 212,208,200 $TextBox2.BorderStyle = 0 $TextBox2.ReadOnly = "True" $TextBox2.TabStop = "False" ;**************************************
;************* ProgForm ************** $ProgForm = $System.Form() $ProgForm.FormBorderStyle = 0 $ProgForm.Height = 60 $ProgForm.StartPosition = 4 $ProgForm.Text = "" $ProgForm.TopMost = "True" $ProgForm.Width = 300 ;**************************************
;************* PBar1 ************** $PBar1 = $ProgForm.Controls.ProgressBar("PBar1", 15, 30, 267, 11) ;**************************************
;************* Label1 ************** $Label1 = $ProgForm.Controls.Label("Searching AD for Usernames", 60, 10, 170, 16)
;KD END
$UnlockButton.Enabled = "False" $ResetButton.Enabled = "False"
$Form.Show $UserIDTextBox.SetFocus() While $Form.Visible $=Execute($Form.DoEvents()) Loop Exit 1
;**********************************************************************************************************************
Function Find() $TextBox1.text = $UserIDTextBox.text Clear() $ADForm.Show LoadListBox() Finduser(1) $TextBox1.SetFocus() $rc = SENDKEYS ("^{RIGHT}") EndFunction
Function LoadListBox() if ubound($arrNames) < 1 $ProgForm.Show $ldap="LDAP://"+@domain+"/"+GetObject("LDAP://rootDSE").Get("defaultNamingContext") $ou = EnumOUs($ldap, 'user') $ProgForm.Hide
redim $arrNames[$ListBox1.ListCount] for $element=0 to $ListBox1.ListCount - 1 $ListBox1.ListIndex = $element $arrNames[$element] = $ListBox1.Text next else $ListBox1.List = $arrNames $listbox1.removeitem(0) endif $ListBox1.listindex = 0 EndFunction
Function ListBoxClicked() $TextBox1.text = $ListBox1.Text $TextBox1.SetFocus() $rc = SENDKEYS ("^{RIGHT}") EndFunction
Function ListBoxdblClicked() $ADForm.Hide $UserIDTextBox.text = $TextBox1.text $UserIDTextBox.SetFocus() $rc = SENDKEYS ("^{RIGHT}") GetUser() EndFunction
Function Finduser(optional $skip) select case $TextBox1.KeyCode=13 and not $skip $ADForm.Hide $TextBox1.text = $ListBox1.Text $UserIDTextBox.text = $TextBox1.text $UserIDTextBox.SetFocus() $rc = SENDKEYS ("^{RIGHT}") GetUser() case $TextBox1.KeyCode=40 and not $skip and $ListBox1.ListIndex +1 < $ListBox1.ListCount $ListBox1.ListIndex = $ListBox1.ListIndex +1 $TextBox1.text = $ListBox1.Text $TextBox1.SetFocus() $rc = SENDKEYS ("^{RIGHT}") case $TextBox1.KeyCode=38 and not $skip and $ListBox1.ListIndex -1 > 0 $ListBox1.ListIndex = $ListBox1.ListIndex -1 $TextBox1.text = $ListBox1.Text $TextBox1.SetFocus() $rc = SENDKEYS ("^{RIGHT}") case 1 for $element=0 to $ListBox1.ListCount - 1 if left($ListBox1.List($element),len($TextBox1.text))=$TextBox1.text $ListBox1.ListIndex = $element $element = $ListBox1.ListCount endif next endselect EndFunction
Function EnterUser() If $UserIDTextBox.KeyCode=13 $userobj = 0 GetUser() EndIf EndFunction
Function Getuser() $userobj = getobject("WinNT://@LDOMAIN/"+$UserIDTextBox.text+",user") if $userobj $UserNameTextBox.Text = $userobj.FullName +" connected" + @crlf + "Last Logon: "+ $userobj.LastLogin + @crlf + "Password Expiration date: "+ $userobj.PasswordExpirationDate + @crlf + " " $AcctLockedCheckBox.Checked = $UserObj.IsAccountLocked $DisabledCheckBox.Checked = $UserObj.AccountDisabled $PassExpiredCheckBox.Checked = $UserObj.PasswordExpired $UnlockButton.Enabled = "True" $ResetButton.Enabled = "True" else $UnlockButton.Enabled = "False" $ResetButton.Enabled = "False" Find() endif endfunction
Function Unlock() if $UserObj $SI = 0 if $UserObj.IsAccountLocked $UserObj.IsAccountLocked = 0 $SI = 1 endif if $UserObj.AccountDisabled $UserObj.AccountDisabled = 0 $SI = 1 endif if $SI = 1 $userobj.SetInfo endif GetUser() endif EndFunction
Function ResetPassword() if $UserObj $UserObj.PasswordExpired = 1 $userobj.setPassword($DefPWD) $userobj.SetInfo GetUser() endif Endfunction
Function Clear() $userobj = 0 $UserNameTextBox.text = '' $UserIDTextBox.text = '' $AcctLockedCheckBox.Checked = 0 $DisabledCheckBox.Checked = 0 $PassExpiredCheckBox.Checked = 0 $UnlockButton.Enabled = "False" $ResetButton.Enabled = "False" endfunction
Function EnumOUs($LDAP, $Filter) dim $aFilter[0], $pos, $objOU, $i, $j
if $Filter <> 'user' $Filter = 'computer' endif $objOU = GetObject($LDAP) if VarTypeName($objOU)='Object' $aFilter[0] = $Filter $objOU.Filter = $aFilter for each $item in $objOU $PBar1.Value = iif($PBar1.Value < $PBar1.Max,$PBar1.Value + 1,0) ;for progress bar only if $item.class = $Filter $ListBox1.AddItem($item.sAMAccountName) $TextBox2.text = '' + $ListBox1.ListCount + ' Items found' $i = $LDAP endif next $aFilter[0] = "organizationalUnit" $objOU.Filter = $aFilter for each $item in $objOU $PBar1.Value = iif($PBar1.Value < $PBar1.Max,$PBar1.Value + 1,0) ;for progress bar only $Name = $item.Name $pos = instrrev($LDAP,"/") $DN = Left($LDAP,$pos) + $Name + ", " + substr($LDAP, $pos+1) $j = EnumOUs($DN, $Filter) if $j $i = iif($i,$i +"|"+ $j,$j) endif next endif $EnumOUs = $i Endfunction
|
Top
|
|
|
|
#166444 - 2006-08-30 10:14 PM
Re: ADSI enable reset user acct KixForm
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
guess some day should start back on that.
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 262 anonymous users online.
|
|
|