Page 1 of 4 1234>
Topic Options
#85200 - 2002-03-11 06:05 PM Kixforms: Manage User Details - Here`s MUD in your eye !
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Gang,

Well, since nobody thought KiXlander was neat [Wink] 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
#85201 - 2002-03-11 07:31 PM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
Alex.H Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 406
Loc: France
Hey Shawn, great you came back to Kixforms
Your script remind me of something ... dunno really remember what [Big Grin]
Just kidding, it is really neat. I always like script bringing KiXtart to a such level
_________________________
? getobject(Kixtart.org.Signature)

Top
#85202 - 2002-03-11 07:54 PM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
Shawn Administrator Offline
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 [Wink] ... hope noone thinks im spamming the board here !

-Shawn

Top
#85203 - 2002-07-12 04:09 AM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Hey... I like this Shawn. I'm gonna have to try and find some time to play around with it.

Thanks for working on this kind of stuff.

Top
#85204 - 2002-07-12 04:29 AM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
MCA Offline
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 ]
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#85205 - 2002-07-12 10:06 AM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
better late than never...

I was wondering why this oldie had popped up on the list, but you guys had found it!

still testing before using is needed as done for build 8.
also, the kixtart release may differ the code functionality.

cheers,
_________________________
!

download KiXnet

Top
#85206 - 2002-07-12 11:13 AM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
Mark Bennett Offline
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
#85207 - 2002-07-12 08:48 PM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Thanks guys.

MCA, I would be most honored if you would host Kixforms off your website. Latest version is Build 20 ... dll,doc,and readme are in zip ... will advise and copy you on any updates as they happen. Thanks again.

-Shawn

Top
#85208 - 2002-07-12 08:54 PM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
MCA Offline
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.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#85209 - 2002-07-12 11:30 PM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Shawn,

A suggestion for your package: add those nice examples to it.
Possible interesting ones are:
Where is KiXlander - Game by Shawn
Manage User Details - Here`s MUD in your eye !
KiXtart PiXaso Painter - Unlease Your Artistic Flare - Part II
Poket Poker - Know when to hold 'em
KixMenu - Dynamically build button menus from INI configuration files
KiXtart Messenger - A thin skin for the NET SEND command

The nice related picture are










It our history page will will add above URL links. They are too nice.
greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#85210 - 2002-07-12 11:33 PM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
wow, these are flaming now... [Eek!]
_________________________
!

download KiXnet

Top
#85211 - 2002-07-13 01:43 AM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
MCA Offline
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.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#85212 - 2002-07-17 10:07 AM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
Raceeend Offline
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
#85213 - 2002-07-18 02:55 PM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Eagle-eye Martijn, thanks for spotting (and fixing!) that.
Top
#85214 - 2002-07-23 03:37 PM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
Raceeend Offline
Starting to like KiXtart

Registered: 2002-05-09
Posts: 129
Loc: The Netherlands
no problem [Smile]
_________________________
regards, Martijn

Top
#85215 - 2002-08-02 08:38 PM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
Incognito Offline
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
#85216 - 2002-08-16 07:31 PM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
Bonji Offline
Starting to like KiXtart

Registered: 2001-09-28
Posts: 169
Loc: Virginia
Shawn,

I took this great User Manager script and modified it to allow non-admins to use it effectively (Only change password and unlock account can be manipluated, though the rest can be seen). If you are an administrator (specifically a member of Domain Admins) then all options are opened up to you. I also added some error-checking in case you try to make a change that you are not allowed to: it informs you that the procedure failed. Along with a few cosmetic changes, this is a KiX'n script. The only problem I've seen so far is that Bad Logins never gets reported. It appears to never return a value. Our policy is set to lock accounts after 3 failed attempts. Any feedback would be greatly appreciated.

Also, I'm going to write a rather involved script to manage every aspect of a Windows 2000 domain possible through ADSI (that I need to do). But before I begin I just wanted to inquire if this has been done before. I've done some extensive searching through the board and have found bits and pieces, but nothing comprehensive. Just wondered if anyone was aware of any such script.

BTW, if anyone is curious about this User Manager script, let me know and I'll post it. Just didn't want to post the code if no one is interested.

Thanks,
Ben Dulaney

[ 16. August 2002, 19:39: Message edited by: Ben Dulaney ]

Top
#85217 - 2002-08-16 07:49 PM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Hi Ben, im very excited about this ... yes please, if its not too big post it ... else email me the script at the address in my profile ... im just doing some finishing touches to Kixforms 2.0 and would love to try out your script ... will it run in any environment without change - or is it specific to your domain ?

-Shawn

Top
#85218 - 2002-08-16 08:25 PM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
[Smile]

Ben...

Not only is this a practical app, but also it is very instructive for those of us new to forms design if we can examine how the code is built.

I am anxious to develop a formbased utility kit of some variety for distribution to non-admin users, but find it frustrating when syntax becomes the roadblock.

I guess what I'm really looking for is "Kixforms for Dummies" to get me off the ground...

Cheers...
_________________________
We all live in a Yellow Subroutine...

Top
#85219 - 2002-08-16 08:49 PM Re: Kixforms: Manage User Details - Here`s MUD in your eye !
Bonji Offline
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 [Smile] .
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
Page 1 of 4 1234>


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 557 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.13 seconds in which 0.056 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org