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 $picBanner = $fraBanner.Image $picBanner.Picture = "shell32.dll;23" $picBanner.HEIGHT = 60 $picBanner.LEFT = 5 $picBanner.TOP = 5 $picBanner.WIDTH = 60 $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 (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(70,0,"User Manager") $fraBanner.FONTSIZE = 8 $fraBanner.ForeColor = $FORM.RGB(0,100,100) $fraBanner.PrintXY(73,32,"Powered by KiX v@KIX and Kixforms v"+$Form.Version) $fraBanner.FONTBOLD = 1 $fraBanner.FONTSIZE = 11 $fraBanner.PrintXY(73,46,"Welcome @FULLNAME") $fraBanner.FONTBOLD = 0 $fraBanner.FONTSIZE = 10 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 = 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 = $ADMINUSER $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 been enabled.", "User enabled") ELSE $=$FORM.MsgBox("The user (" + $strUserName + ") could not be enabled.","Not Authorized") ENDIF Else ; Disable Account $adsUser.AccountDisabled = 1 $adsUser.SetInfo IF @ERROR=0 $= $FORM.MsgBox("The user (" + $strUserName + ") has been disabled.", "User disabled") ELSE $=$FORM.MsgBox("The user (" + $strUserName + ") could 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 been unlocked.", "User enabled") ELSE $=$FORM.MsgBox("The user (" + $strUserName + ") could not be unlocked.","Not Authorized") $chkAccountLocked.Value = 1 ENDIF EndIf ; Disable the checkbox $chkAccountLocked.Enabled = 0 $adsUser = Nothing EndFunction Function cmdSetPassword_Click() $adsUser = GetObject($strUserPath) If $txtPassword.Text = "" $= $FORM.MsgBox("The password cannot be empty.", "User password change") Else If Len($txtPassword.Text) < 6 $= $FORM.MsgBox("The password cannot be less than 6 characters long.", "User password change") Else $adsUser.SetPassword($txtPassword.Text) IF @ERROR=0 $=$FORM.MsgBox("The password has been changed to (" + $txtPassword.Text + ").", "User Password Change") ELSE $=$FORM.MsgBox("The password could not be 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.", "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 due to an error.", "User expire date change") Else $= $FORM.MsgBox("Expiration date is changed to (" + $txtExpiryDate.Text + ").", "User expire date change") EndIf EndIf $adsUser = Nothing EndFunction