#85200 - 2002-03-11 06:05 PM
Kixforms: Manage User Details - Here`s MUD in your eye !
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
Gang,
Well, since nobody thought KiXlander was neat here`s a prototype of a new script that allows one to "quicky" Manage User Details (MUD) using Active Directory. Instead of using USRMGR for domains, and having to enumerate all those users and groups into a listbox, this script allows one to perform a single user query, then (in this release) set the password and enable/disable the account.
The reason its a prototype is that it will be using some of the new features of the next release, like setting the PasswordChar on a textbox, etc.
To run this script, you will need a Windows 2K/XP machine, KiXtart 4.0 and the Kixforms Library Build 8, and you can get that from here:
The Kixforms Library
Heres a screenshot:
And heres the script:
code:
Break On
; REQUIRES: ; ; KIXTART 4.02 ; KIXFORMS BUILD 8 ; WINDOWS 2K/XP ; $Form = CreateObject("Kixtart.Form") $Form.Caption = "Modify User Details - KiXtart" $Form.ScaleHeight = 506 $Form.ScaleWidth = 600 $Form.FontName = "Arial" $Form.FontSize = 9 $Form.Center $fraBanner = $Form.PictureBox $fraBanner.BackColor = $Form.RGB(255,255,255) $fraBanner.Height = 137 $fraBanner.Left = 10 $fraBanner.Top = 10 $fraBanner.Width = 585 $fraDetails = $Form.Frame("Details") $fraDetails.Height = 345 $fraDetails.Left = 8 $fraDetails.Top = 152 $fraDetails.Width = 585 $txtUsername = $fraDetails.TextBox $txtUsername.Height = 25 $txtUsername.Left = 104 $txtUsername.Top = 24 $txtUsername.Text = "" $txtUsername.Width = 161 $cmdFindUser = $fraDetails.CommandButton("Find User!") $cmdFindUser.Default = 1 ; True $cmdFindUser.FontName = "Comic Sans MS" $cmdFindUser.FontSize = 12 $cmdFindUser.FontBold = 1 $cmdFindUser.Left = 272 $cmdFindUser.Top = 24 $cmdFindUser.Width = 129 $cmdFindUser.OnClick = "cmdFindUser_Click()" $txtDisplayName = $fraDetails.TextBox $txtDisplayName.Height = 25 $txtDisplayName.Left = 104 $txtDisplayName.TabStop = 0 ; False $txtDisplayName.Top = 56 $txtDisplayName.Width = 297 $txtDisplayName.Enabled = 1 $txtDisplayName.BackColor = $Form.BackColor $lblDisplayName = $fraDetails.Label("Full Name:") $lblDisplayName.Width = 75 $lblDisplayName.Left = $txtDisplayName.Left - $lblDisplayName.Width $lblDisplayName.Top = $txtDisplayName.Top $txtPassword = $fraDetails.TextBox $txtPassword.Height = 25 $txtPassword.Left = 104 $txtPassword.PasswordChar = "" $txtPassword.Top = 88 $txtPassword.Width = 161 $txtPassword.Enabled = 0 $cmdSetPassword = $fraDetails.CommandButton("Set Password!") $cmdSetPassword.FontName = "Comic Sans MS" $cmdSetPassword.FontSize = 12 $cmdSetPassword.FontBold = 1 $cmdSetPassword.Left = 272 $cmdSetPassword.Top = 88 $cmdSetPassword.Width = 129 $cmdSetPassword.Enabled = 0 $cmdSetPassword.OnClick = "cmdSetPassword_Click()" $txtExpiryDate = $fraDetails.TextBox $txtExpiryDate.Height = 25 $txtExpiryDate.Left = 104 $txtExpiryDate.Top = 120 $txtExpiryDate.Width = 161 $txtExpiryDate.Enabled = 0 $lblPassword = $fraDetails.Label("Password:") $lblPassword.Width = 75 $lblPassword.Left = $txtPassword.Left - $lblPassword.Width $lblPassword.Top = $txtPassword.Top $lblExpiryDate = $fraDetails.Label("Expiry Date:") $lblExpiryDate.Width = 75 $lblExpiryDate.Left = $txtExpiryDate.Left - $lblExpiryDate.Width $lblExpiryDate.Top = $txtExpiryDate.Top $cmdChangeExpiryDate = $fraDetails.CommandButton("Change Date!") $cmdChangeExpiryDate.FontName = "Comic Sans MS" $cmdChangeExpiryDate.FontSize = 12 $cmdChangeExpiryDate.FontBold = 1 $cmdChangeExpiryDate.Left = 272 $cmdChangeExpiryDate.Top = 120 $cmdChangeExpiryDate.Width = 129 $cmdChangeExpiryDate.OnClick = "cmdChangeExpiryDate_Click()" $cmdChangeExpiryDate.Enabled = 0 $lstGroups = $fraDetails.ListBox $lstGroups.Height = 134 $lstGroups.Left = 104 $lstGroups.Top = 152 $lstGroups.Width = 297 $lstGroups.Enabled = 0 $lblGroups = $fraDetails.Label("Groups:") $lblGroups.Width = 75 $lblGroups.Left = $lstGroups.Left - $lblGroups.Width $lblGroups.Top = $lstGroups.Top $txtBadLoginCount = $fraDetails.TextBox $txtBadLoginCount.Height = 25 $txtBadLoginCount.Left = 104 $txtBadLoginCount.TabStop = 0 ; False $txtBadLoginCount.Top = 296 $txtBadLoginCount.Width = 161 $txtBadLoginCount.BackColor = $Form.BackColor $lblBadLoginCount = $fraDetails.Label("Bad Logins:") $lblBadLoginCount.Width = 75 $lblBadLoginCount.Left = $txtBadLoginCount.Left - $lblBadLoginCount.Width $lblBadLoginCount.Top = $txtBadLoginCount.Top $cmdExit = $fraDetails.CommandButton("Exit!") $cmdExit.FontName = "Comic Sans MS" $cmdExit.FontSize = 12 $cmdExit.FontBold = 1 $cmdExit.Top = 296 $cmdExit.Width = 129 $cmdExit.Left = 445 $cmdExit.OnClick = "quit()" $fraStatus = $fraDetails.Frame $fraStatus.BackColor = $Form.BackColor $fraStatus.Caption = "Account Status" $fraStatus.Height = 105 $fraStatus.Left = 420 ; 416 $fraStatus.Top = 20 ; 224 $fraStatus.Width = 155 $chkAccountDisabled = $fraStatus.CheckBox("Account Disabled") $chkAccountDisabled.Left = 10 $chkAccountDisabled.TabStop = 0 ; False $chkAccountDisabled.Top = 24 $chkAccountDisabled.OnClick = "chkAccountDisabled_Click()" $chkAccountDisabled.Enabled = 0 $chkAccountLocked = $fraStatus.CheckBox("Account Locked") $chkAccountLocked.Caption = "Account Locked" $chkAccountLocked.Left = 10 $chkAccountLocked.TabStop = 0 ; False $chkAccountLocked.Top = 56 $chkAccountLocked.OnClick = "chkAccountLocked_Click()" $chkAccountLocked.Enabled = 0 $lblUsername = $fraDetails.Label $lblUsername.Caption = "Username:" $lblUsername.Height = $txtUsername.Height $lblUsername.Width = 75 $lblUsername.Left = $txtUsername.Left - $lblUsername.Width $lblUsername.Top = $txtUsername.Top ; Draw on the banner $fraBanner.FontSize = 16 $fraBanner.FontName = "verdana" $fraBanner.FontSize = 28 $fraBanner.ForeColor = $Form.RGB(100,200,200) $fraBanner.PrintXY(23,10,"Modify User Details") $fraBanner.ForeColor = 0 $fraBanner.PrintXY(20,7,"Modify User Details") $fraBanner.FontSize = 12 $fraBanner.ForeColor = $Form.RGB(0,100,100) $fraBanner.PrintXY(23,58,"Powered by KiXtart v@KIX and Kixforms Build 8") $fraBanner.FontBold = 1 $fraBanner.PrintXY(23,80,"Welcome @USERID") $fraBanner.FontBold = 0 $fraBanner.FontSize = 10 $fraBanner.ForeColor = $Form.RGB(0,100,100)
Dim $strUserName Dim $strUserPath $txtUsername.SelLength = Len($txtUsername.Text) $Form.Show $txtUsername.SetFocus
While $Form.Visible $=Execute($Form.DoEvents) Loop Exit 1 Function cmdFindUser_Click() Dim $Wait $Wait = CreateObject("Kixtart.Form") $Wait.Caption = "One moment please..." $Wait.ScaleWidth = 500 $Wait.ScaleHeight = 100 $Wait.FontSize = 14 $Wait.FontName = "Arial" $Wait.PrintXY(30,30,"Searching Active Directory, one moment please...") $Wait.Center
Dim $adsUser,$adsGroup If $txtUsername.Text = "" $= $Form.MsgBox("You must specify a username before clicking Find.", "Username invalid") $txtUsername.Text = $strUserName Exit Sub Else $strUserName = $txtUsername.Text Endif $Wait.Show
$strUserPath = "WinNT://@LDOMAIN/$strUserName,User" $adsUser = GetObject($strUserPath) If Not $adsUser ; User does not exist $= $Form.MsgBox("A user called (" + $txtUsername.Text + ") does not exist.", "Username invalid") ; Disable the controls $chkAccountDisabled.Enabled = 0 $cmdSetPassword.Enabled = 0 $cmdChangeExpiryDate.Enabled = 0 $txtPassword.Enabled = 0 $cmdChangeExpiryDate.Enabled = 0 $txtPassword.Text = "" $txtDisplayName.Text = "" $txtExpiryDate.Text = "" $txtBadLoginCount.Text = "" $lstGroups.Clear Else $txtPassword.Text = "" $txtDisplayName.Text = "" $txtExpiryDate.Text = "" $txtBadLoginCount.Text = "" $lstGroups.Clear $lstGroups. ; User exists so bind to it $adsUser.GetInfo $txtDisplayName.Text = $adsUser.FullName $txtExpiryDate.Text = $adsUser.AccountExpirationDate If $adsUser.AccountDisabled ; Check the disabled box $chkAccountDisabled.Value = 1 Else ; Uncheck the disabled box $chkAccountDisabled.Value = 0 EndIf If $adsUser.IsAccountLocked ; Check the locked box $chkAccountLocked.Value = 1 ; Enable the checkbox so that the account can be unlocked $chkAccountLocked.Enabled = True Else ; Uncheck the locked box $chkAccountLocked.Value = 0 EndIf For Each $adsGroup In $adsUser.Groups $lstGroups.AddItem ($adsGroup.Name) Next $strBLC = $adsUser.BadLoginCount If @ERROR $txtBadLoginCount.Text = 0 Else $txtBadLoginCount.Text = $strBLC EndIf ;Enable the controls $chkAccountDisabled.Enabled = 1 $cmdSetPassword.Enabled = 1 $cmdChangeExpiryDate.Enabled = 1 $txtPassword.Enabled = 1 $txtExpiryDate.Enabled = 1 $lstGroups.Enabled = 1 $adsUser = 0 $adsGroup = 0 $txtUsername.SetFocus Endif $Form.Refresh $txtUsername.SetFocus EndFunction Function chkAccountDisabled_Click() Dim $adsUser $adsUser = GetObject($strUserPath) $adsUser.GetInfo If $chkAccountDisabled.Value = 0 ; Enable account $adsUser.AccountDisabled = 0 $adsUser.SetInfo $= $Form.MsgBox("The user (" + $strUserName + ") has been enabled.", "User enabled") Else ; Disable Account $adsUser.AccountDisabled = 1 $adsUser.SetInfo $= $Form.MsgBox("The user (" + $strUserName + ") has been disabled.", "User disabled") EndIf $adsUser = 0 EndFunction Function chkAccountLocked_Click() Dim $adsUser If $chkAccountLocked.Value = 0 ; Unlock the account $adsUser = GetObject($strUserPath) $adsUser.GetInfo $adsUser.IsAccountLocked = 0 $adsUser.SetInfo $= $Form.MsgBox("The user (" + $strUserName + ") has been unlocked.", "User enabled") EndIf ; Disable the checkbox $chkAccountLocked.Enabled = 0 $adsUser = Nothing EndFunction Function cmdSetPassword_Click() $adsUser = GetObject($strUserPath) $adsUser.GetInfo If $txtPassword.Text = "" $= $Form.MsgBox("The password cannot be empty.", "User password change", 1) Else If Len($txtPassword.Text) < 6 $= $Form.MsgBox("The password cannot be less than 6 characters long.", "User password change", 1) Else $adsUser.SetPassword($txtPassword.Text) $= $Form.MsgBox("The password has been changed to (" + $txtPassword.Text + ").", "User password change", 1) EndIf EndIf $txtPassword.Text = "" $adsUser = Nothing EndFunction Function cmdChangeExpiryDate_Click() Dim $adsUser $adsUser = GetObject($strUserPath) $adsUser.GetInfo If $txtExpiryDate.Text = "" $= $Form.MsgBox("The expiry date cannot be empty.", "User expiry date change", 1) $txtExpiryDate.Text = $adsUser.AccountExpirationDate Else $adsUser.AccountExpirationDate = $txtExpiryDate.Text $adsUser.SetInfo If @ERROR $= $Form.MsgBox("The expiry date has not been changed due to an error.", "User expiry date change") Else $= $Form.MsgBox("The expiry date been changed to (" + $txtExpiryDate.Text + ").", "User expiry date change") EndIf EndIf $adsUser = Nothing EndFunction
-Shawn [ 16 March 2002, 15:18: Message edited by: Shawn ]
|
Top
|
|
|
|
#85202 - 2002-03-11 07:54 PM
Re: Kixforms: Manage User Details - Here`s MUD in your eye !
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
Hi Alex,
Yeah, this script might seem familar, it was lifted from a book on Active Directory Admin - don`t have the book with me right now and I forget the exact title and author (its an O`Reilly book though) ... got another script Im going to post in a minute or two. Its about 90% original ... hope noone thinks im spamming the board here !
-Shawn
|
Top
|
|
|
|
#85204 - 2002-07-12 04:29 AM
Re: Kixforms: Manage User Details - Here`s MUD in your eye !
|
MCA
KiX Supporter
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear Shawn,
It looks very nice. Without your description on the picture nobody from the past thinks this can be done with kixtart. Just with the fundaments from Ruud and the great effort from you and some other guys every- body can use these great things.
If you like we will put this nice kixtart extension on our site. Again a great great work. greetings.
btw: we doesn't saw the picture earlier because we had supress them in the past. A too slow connection at that time. [ 12 July 2002, 05:04: Message edited by: MCA ]
|
Top
|
|
|
|
#85206 - 2002-07-12 11:13 AM
Re: Kixforms: Manage User Details - Here`s MUD in your eye !
|
Mark Bennett
Getting the hang of it
Registered: 2001-10-10
Posts: 70
|
This is superb! Provides some useful functionality and gives some great examples of code for forms and Active Directory. Mark
|
Top
|
|
|
|
#85208 - 2002-07-12 08:54 PM
Re: Kixforms: Manage User Details - Here`s MUD in your eye !
|
MCA
KiX Supporter
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Thanks Shawn,
We just want to put most used kixtart add-ons on one place. Each to find, but we will never forget to point to the original URL location. Possible that next week we get more information about such similar programs after ending the POLL. greetings.
|
Top
|
|
|
|
#85209 - 2002-07-12 11:30 PM
Re: Kixforms: Manage User Details - Here`s MUD in your eye !
|
MCA
KiX Supporter
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
|
Top
|
|
|
|
#85211 - 2002-07-13 01:43 AM
Re: Kixforms: Manage User Details - Here`s MUD in your eye !
|
MCA
KiX Supporter
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear,
Now you can download also Kixforms from our site. For interesting links about this nice and useful tool see also our History of Site page. greetings.
|
Top
|
|
|
|
#85212 - 2002-07-17 10:07 AM
Re: Kixforms: Manage User Details - Here`s MUD in your eye !
|
Raceeend
Starting to like KiXtart
Registered: 2002-05-09
Posts: 129
Loc: The Netherlands
|
Hi Shawn,
Nice usermanager you made it works great. But i found one error when i ran it.
If an account (NT4.0 domain) is locked out it is not possible to unlock it.
i changed:
$chkAccountLocked.Enabled = True
into
$chkAccountLocked.Enabled = 1
and now it works fine.
_________________________
regards,
Martijn
|
Top
|
|
|
|
#85215 - 2002-08-02 08:38 PM
Re: Kixforms: Manage User Details - Here`s MUD in your eye !
|
Incognito
Getting the hang of it
Registered: 2001-07-09
Posts: 66
|
You should have your utility create the user directory and give an option to make the share at a default user location. (with an option for it to be hidden of course.)
|
Top
|
|
|
|
#85219 - 2002-08-16 08:49 PM
Re: Kixforms: Manage User Details - Here`s MUD in your eye !
|
Bonji
Starting to like KiXtart
Registered: 2001-09-28
Posts: 169
Loc: Virginia
|
I sent an email to you Shawn with the script and some additional info. The code should work in any environment without changes. It could probably use a little cleanup as I haven't gone over it cosmetically at this point. But anyway, here it is...
*UPDATE* I just added functionality so that the script gets the Minimum Password Value from the Domain and uses that to check against the length of the new password set instead of just using the number 6. Hopefully the new code copies OK . code:
BREAK ON
; REQUIRES: ; ; KIXTART 4.02 ; KIXFORMS BUILD 27 ; WINDOWS 2K/XP ; ; WRITTEN BY SHAWN TASSIE ; MODIFIED BY BEN DULANEY ; Find out if User is an Administrator, if so enable all features $ADMINUSER=0 $ADSUSER1=GETOBJECT("WinNT://@LDOMAIN/@USERID,User") FOR EACH $ELEMENT IN $ADSUSER1.GROUPS IF $ELEMENT.NAME="DOMAIN ADMINS" $ADMINUSER=1 ENDIF NEXT
$FORM = CREATEOBJECT("Kixtart.FORM")
$FORM.CAPTION = "User Manager" $FORM.SCALEHEIGHT = 402 $FORM.SCALEWIDTH = 600 $FORM.FONTNAME = "Arial" $FORM.FONTSIZE = 9 $FORM.CENTER
$fraBanner = $FORM.PictureBox $fraBanner.BACKCOLOR = $FORM.RGB(255,255,255) $fraBanner.HEIGHT = 70 $fraBanner.LEFT = 10 $fraBanner.TOP = 10 $fraBanner.WIDTH = 585
$fraDetails = $FORM.Frame("Details") $fraDetails.HEIGHT = 300 $fraDetails.LEFT = 8 $fraDetails.TOP = 95 $fraDetails.WIDTH = 585 $txtUsername = $fraDetails.TextBox $txtUsername.HEIGHT = 19 $txtUsername.LEFT = 104 $txtUsername.TOP = 24 $txtUsername.Text = "" $txtUsername.WIDTH = 161 $cmdFindUser = $fraDetails.CommandButton("Find User") $cmdFindUser.DEFAULT = 1 ; True $cmdFindUser.FONTNAME = "Arial" $cmdFindUser.FONTSIZE = 10 $cmdFindUser.FONTBOLD = 1 $cmdFindUser.LEFT = 272 $cmdFindUser.TOP = 24 $cmdFindUser.WIDTH = 129 $cmdFindUser.HEIGHT = 19 $cmdFindUser.OnClick = "cmdFindUser_Click()" $txtDisplayName = $fraDetails.TextBox $txtDisplayName.HEIGHT = 19 $txtDisplayName.LEFT = 104 $txtDisplayName.TabStop = 0 ; False $txtDisplayName.TOP = 56 $txtDisplayName.WIDTH = 297 $txtDisplayName.Enabled = 1 $txtDisplayName.BACKCOLOR = $FORM.BACKCOLOR $lblDisplayName = $fraDetails.Label("Full Name:") $lblDisplayName.WIDTH = 75 $lblDisplayName.LEFT = $txtDisplayName.LEFT - $lblDisplayName.WIDTH $lblDisplayName.TOP = $txtDisplayName.TOP $txtPassword = $fraDetails.TextBox $txtPassword.HEIGHT = 19 $txtPassword.LEFT = 104 $txtPassword.PasswordChar = "" $txtPassword.TOP = 88 $txtPassword.WIDTH = 161 $txtPassword.Enabled = 0 $cmdSetPassword = $fraDetails.CommandButton("Set Password") $cmdSetPassword.FONTNAME = "Arial" $cmdSetPassword.FONTSIZE = 10 $cmdSetPassword.FONTBOLD = 1 $cmdSetPassword.LEFT = 272 $cmdSetPassword.TOP = 88 $cmdSetPassword.WIDTH = 129 $cmdSetPassword.HEIGHT = 19 $cmdSetPassword.Enabled = 0 $cmdSetPassword.OnClick = "cmdSetPassword_Click()" $txtExpiryDate = $fraDetails.TextBox $txtExpiryDate.HEIGHT = 19 $txtExpiryDate.LEFT = 104 $txtExpiryDate.TOP = 120 $txtExpiryDate.WIDTH = 161 $txtExpiryDate.Enabled = 0 $lblPassword = $fraDetails.Label("Password:") $lblPassword.WIDTH = 75 $lblPassword.LEFT = $txtPassword.LEFT - $lblPassword.WIDTH $lblPassword.TOP = $txtPassword.TOP $lblExpiryDate = $fraDetails.Label("Expire Date:") $lblExpiryDate.WIDTH = 75 $lblExpiryDate.LEFT = $txtExpiryDate.LEFT - $lblExpiryDate.WIDTH $lblExpiryDate.TOP = $txtExpiryDate.TOP $cmdChangeExpiryDate = $fraDetails.CommandButton("Change Date") $cmdChangeExpiryDate.FONTNAME = "Arial" $cmdChangeExpiryDate.FONTSIZE = 10 $cmdChangeExpiryDate.FONTBOLD = 1 $cmdChangeExpiryDate.LEFT = 272 $cmdChangeExpiryDate.TOP = 120 $cmdChangeExpiryDate.WIDTH = 129 $cmdChangeExpiryDate.HEIGHT = 19 $cmdChangeExpiryDate.OnClick = "cmdChangeExpiryDate_Click()" $cmdChangeExpiryDate.Enabled = 0 $lstGroups = $fraDetails.ListBox $lstGroups.HEIGHT = 134 $lstGroups.LEFT = 104 $lstGroups.TOP = 152 $lstGroups.WIDTH = 297 $lstGroups.Enabled = 0 $lblGroups = $fraDetails.Label("Groups:") $lblGroups.WIDTH = 75 $lblGroups.LEFT = $lstGroups.LEFT - $lblGroups.WIDTH $lblGroups.TOP = $lstGroups.TOP $txtBadLoginCount = $fraDetails.TextBox $txtBadLoginCount.HEIGHT = 19 $txtBadLoginCount.LEFT = 9 + 420 + 75 $txtBadLoginCount.TabStop = 0 ; False $txtBadLoginCount.TOP = 26 + 20 + 105 $txtBadLoginCount.WIDTH = 20 $txtBadLoginCount.BACKCOLOR = $FORM.BACKCOLOR $lblBadLoginCount = $fraDetails.Label("Bad Logins:") $lblBadLoginCount.WIDTH = 75 $lblBadLoginCount.LEFT = 9 + 420 ; X + Y (Y = $fraStatus.LEFT) $lblBadLoginCount.TOP = 26 + 20 + 105 ; X + Y + Z CHOPPED (Y = $fraStatus.TOP & Z = $fraStatus.HEIGHT) $cmdExit = $fraDetails.CommandButton("Exit") $cmdExit.FONTNAME = "Arial" $cmdExit.FONTSIZE = 10 $cmdExit.FONTBOLD = 1 $cmdExit.TOP = 267 $cmdExit.WIDTH = 129 $cmdExit.HEIGHT = 19 $cmdExit.LEFT = 445 $cmdExit.OnClick = "quit()" $fraStatus = $fraDetails.Frame $fraStatus.BACKCOLOR = $FORM.BACKCOLOR $fraStatus.CAPTION = "Account Status" $fraStatus.HEIGHT = 105 $fraStatus.LEFT = 420 ; 416 $fraStatus.TOP = 20 ; 224 $fraStatus.WIDTH = 155 $chkAccountDisabled = $fraStatus.CheckBox("Account Disabled") $chkAccountDisabled.LEFT = 10 $chkAccountDisabled.TabStop = 0 ; False $chkAccountDisabled.TOP = 24 $chkAccountDisabled.OnClick = "chkAccountDisabled_Click()" $chkAccountDisabled.Enabled = 0 $chkAccountLocked = $fraStatus.CheckBox("Account Locked") $chkAccountLocked.CAPTION = "Account Locked" $chkAccountLocked.LEFT = 10 $chkAccountLocked.TabStop = 0 ; False $chkAccountLocked.TOP = 56 $chkAccountLocked.OnClick = "chkAccountLocked_Click()" $chkAccountLocked.Enabled = 0 $lblUsername = $fraDetails.Label $lblUsername.CAPTION = "Username:" $lblUsername.HEIGHT = $txtUsername.HEIGHT $lblUsername.WIDTH = 75 $lblUsername.LEFT = $txtUsername.LEFT - $lblUsername.WIDTH $lblUsername.TOP = $txtUsername.TOP ; Draw on the banner $fraBanner.FONTSIZE = 20 $fraBanner.FONTNAME = "verdana" $fraBanner.ForeColor = 0 $fraBanner.PrintXY(20,0,"User Manager") $fraBanner.FONTSIZE = 8 $fraBanner.ForeColor = $FORM.RGB(0,100,100) $fraBanner.PrintXY(23,32,"Powered by KiX v@KIX and Kixforms Build 27") $fraBanner.FONTBOLD = 1 $fraBanner.FONTSIZE = 11 $fraBanner.PrintXY(23,46,"Welcome @FULLNAME") $fraBanner.FONTBOLD = 0 $fraBanner.FONTSIZE = 10
Dim $strUserName Dim $strUserPath Dim $strDomainPath $txtUsername.SelLength = Len($txtUsername.Text) $FORM.Show $txtUsername.SetFocus
While $FORM.Visible $=Execute($FORM.DoEvents) Loop Exit 1 Function cmdFindUser_Click() Dim $Wait $Wait = CREATEOBJECT("Kixtart.FORM") $Wait.CAPTION = "One moment please..." $Wait.SCALEWIDTH = 500 $Wait.SCALEHEIGHT = 100 $Wait.FONTSIZE = 14 $Wait.FONTNAME = "Arial" $Wait.PrintXY(30,30,"Searching Active Directory, one moment please...") $Wait.CENTER Dim $adsUser,$adsGroup
If $txtUsername.Text = "" $= $FORM.MsgBox("You must specify a username before CHOPPED clicking Find.", "Username invalid") $txtUsername.Text = $strUserName Exit Sub Else $strUserName = $txtUsername.Text Endif
$Wait.Show $strUserPath = "WinNT://@LDOMAIN/$strUserName,User" $adsUser = GetObject($strUserPath) If Not $adsUser ; User does not exist $= $FORM.MsgBox("A user called (" + $txtUsername.Text + ") CHOPPED does not exist.", "Username invalid") ; Disable the controls $chkAccountDisabled.Enabled = 0 $cmdSetPassword.Enabled = 0 $cmdChangeExpiryDate.Enabled = 0 $txtPassword.Enabled = 0 $cmdChangeExpiryDate.Enabled = 0 $txtPassword.Text = "" $txtDisplayName.Text = "" $txtExpiryDate.Text = "" $txtBadLoginCount.Text = "" $lstGroups.Clear Else $txtPassword.Text = "" $txtDisplayName.Text = "" $txtExpiryDate.Text = "" $txtBadLoginCount.Text = "" $lstGroups.Clear $lstGroups.
; User exists so bind to it $adsUser.GetInfo $txtDisplayName.Text = $adsUser.FullName $txtExpiryDate.Text = $adsUser.AccountExpirationDate
If $adsUser.AccountDisabled ; Check the disabled box $chkAccountDisabled.Value = 1 Else
; Uncheck the disabled box $chkAccountDisabled.Value = 0 EndIf
If $adsUser.IsAccountLocked ; Check the locked box $chkAccountLocked.Value = 1 ; Enable the checkbox so that the account can be unlocked $chkAccountLocked.Enabled = 1 Else ; Uncheck the locked box $chkAccountLocked.Value = 0 EndIf
For Each $adsGroup In $adsUser.Groups $lstGroups.AddItem ($adsGroup.Name) Next
$strBLC = $adsUser.BadLoginCount If @ERROR $txtBadLoginCount.Text = 0 Else $txtBadLoginCount.Text = $strBLC EndIf ;Enable the controls $chkAccountDisabled.Enabled = $ADMINUSER $cmdSetPassword.Enabled = 1 $cmdChangeExpiryDate.Enabled = $ADMINUSER $txtPassword.Enabled = 1 $txtExpiryDate.Enabled = $ADMINUSER $lstGroups.Enabled = 1 $adsUser = 0 $adsGroup = 0 $txtUsername.SetFocus Endif $FORM.Refresh $txtUsername.SetFocus EndFunction Function chkAccountDisabled_Click() Dim $adsUser $adsUser = GetObject($strUserPath) If $chkAccountDisabled.Value = 0 ; Enable account $adsUser.AccountDisabled = 0 $adsUser.SetInfo IF @ERROR=0 $=$FORM.MsgBox("The user (" + $strUserName + ") has CHOPPED been enabled.", "User enabled") ELSE $=$FORM.MsgBox("The user (" + $strUserName + ") could CHOPPED not be enabled.","Not Authorized") ENDIF Else ; Disable Account $adsUser.AccountDisabled = 1 $adsUser.SetInfo IF @ERROR=0 $= $FORM.MsgBox("The user (" + $strUserName + ") has CHOPPED been disabled.", "User disabled") ELSE $=$FORM.MsgBox("The user (" + $strUserName + ") could CHOPPED not be disabled.","Not Authorized") ENDIF EndIf $adsUser = 0 EndFunction Function chkAccountLocked_Click() Dim $adsUser If $chkAccountLocked.Value = 0 ; Unlock the account $adsUser = GetObject($strUserPath) $adsUser.IsAccountLocked = 0 $adsUser.SetInfo IF @ERROR=0 $=$FORM.MsgBox("The user (" + $strUserName + ") has CHOPPED been unlocked.", "User enabled") ELSE $=$FORM.MsgBox("The user (" + $strUserName + ") could CHOPPED not be unlocked.","Not Authorized") $chkAccountLocked.Value = 1 ENDIF EndIf ; Disable the checkbox $chkAccountLocked.Enabled = 0 $adsUser = Nothing EndFunction Function cmdSetPassword_Click() ; Get Minimum Password Length Allowed from Domain Policy $strDomainPath="WinNT://@LDOMAIN,Domain" $adsDomain = GetObject($strDomainPath) $intMinPasswordLength=$adsDomain.MinPasswordLength $adsDomain = Nothing
$adsUser = GetObject($strUserPath) If $txtPassword.Text = "" $= $FORM.MsgBox("The password cannot be empty.", "User CHOPPED password change") Else If Len($txtPassword.Text) < $intMinPasswordLength $= $FORM.MsgBox("The password cannot be less than " + CHOPPED $intMinPasswordLength + " characters long.", CHOPPED "User password change") Else $adsUser.SetPassword($txtPassword.Text) IF @ERROR=0 $=$FORM.MsgBox("The password has been changed CHOPPED to (" + $txtPassword.Text + ").", "User Password Change") ELSE $=$FORM.MsgBox("The password could not be CHOPPED changed.","Not Authorized") ENDIF EndIf EndIf $txtPassword.Text = "" $adsUser = Nothing EndFunction Function cmdChangeExpiryDate_Click() Dim $adsUser $adsUser = GetObject($strUserPath) If $txtExpiryDate.Text = "" $= $FORM.MsgBox("The expiration date cannot be empty.", CHOPPED "User expire date change") $txtExpiryDate.Text = $adsUser.AccountExpirationDate Else $adsUser.AccountExpirationDate = $txtExpiryDate.Text $adsUser.SetInfo If @ERROR $= $FORM.MsgBox("Expiration date has not been changed CHOPPED due to an error.", "User expire date change") Else $= $FORM.MsgBox("Expiration date is changed to (" + CHOPPED $txtExpiryDate.Text + ").", "User expire date change") EndIf EndIf $adsUser = Nothing EndFunction
BTW, I compacted a few lines so the post wouldn't be so wide. I added the word 'CHOPPED' in front of those lines to make it easy to fix. If someone can tell me how to do that without breaking the code I'll go back and fix it. If it's cut and pasted, it will not work without those lines being fixed.
Thanks, Ben [ 16. August 2002, 21:51: Message edited by: Ben Dulaney ]
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 557 anonymous users online.
|
|
|