My teachers want to restrict access to a color printer. So I'm writing a script that will allow them to enter the name of user(s) or a global group. The script should then apply that list to a loop that will add each object to the appropriate group (using the GroupAdd UDF by Bryce). I'm trying to search for information on what kix commands to use that will create a list of users for the loop to draw on. What search terms should I be using? (I've tried 'inputting users into a script' in Google and this forum but that didn't help).
Thanks,
_________________________
--- Bishop Grandin Technology Department 'Either we're on time, or we're late'
I don't think that's what I'm looking for exactly. I'm looking for the descriptors I should use in a search engine when looking for how to pass user name(s) into a loop. Is that what an array is used for?
_________________________
--- Bishop Grandin Technology Department 'Either we're on time, or we're late'
if the list is input on some text field, you could use "name, name2, name3" format instead. when the input is done, then just do split() on the names string and it becomes array.
So, if I wanted teachers to be able to enter specific names, my kixforms script would look something like this? Code:
$InputBox = $AddToPrinterGroup.InputBox() Show( "Please enter the student user name(s) who should be given access to the Xerox printer."Chr(13)"Seperate names with a semi-colon (;)", Student Name Entry, xpos, ypos) Translate the teacher's entries to variable $names for each $username in $usernames " -> " $username ? next
How do I Translate the teacher's entries to variable $names Thanks,
_________________________
--- Bishop Grandin Technology Department 'Either we're on time, or we're late'
While $ADForm.Visible $=Execute($ADForm.DoEvents()) Loop Exit 1
Function GetUsers() $target = $button $ADForm.Show if $adListBox1.ListCount <1 $ProgForm.Show $oDomain = GetObject("WinNT://@LDomain") $oDomain.filter = "User","" For Each $oUser In $oDomain if instr($oUser.FullName,',') or instr($oUser.FullName,'=') > 0 $adlistbox1.additem($oUser.FullName) $adTextBox2.text = '' + $adListBox1.ListCount + ' Items found' endif $PBar1.Value = iif($PBar1.Value < $PBar1.Max,$PBar1.Value + 1,0) ;for progress bar only Next $ProgForm.Hide Endif $adTextBox1.SetFocus ; $rc = SENDKEYS ("^{END}") EndFunction
Function Finduser(optional $skip) select case $adTextBox1.KeyCode=13 and not $skip ; ******************************************************************** ; ***** This is the section that returns the selected username ***** ; ***** back to your main form ***** ; ***** $ReturnText.text = text of the name ***** ; ***** $ReturnLDAP = the ldap string of the selected acct ***** ; ******************************************************************** $ADForm.Hide $adTextBox1.text = $adListBox1.Text $nameLDAP = TranslateName(1, @domain, 4, $adListBox1.Text, 1) if $nameLDAP[1] = 0 $ReturnText.text = $adListBox1.Text $ReturnLDAP = $nameLDAP[0] endif case $adTextBox1.KeyCode=40 and not $skip and $adListBox1.ListIndex +1 < $adListBox1.ListCount $adListBox1.ListIndex = $adListBox1.ListIndex +1 $adTextBox1.text = $adListBox1.Text $adTextBox1.SetFocus() $rc = SENDKEYS ("^{END}") case $TextBox1.KeyCode=38 and not $skip and $adListBox1.ListIndex -1 > 0 $adListBox1.ListIndex = $adListBox1.ListIndex -1 $adTextBox1.text = $adListBox1.Text $adTextBox1.SetFocus() $rc = SENDKEYS ("^{END}") case 1 for $element=0 to $adListBox1.ListCount - 1 if left($adListBox1.List($element),len($adTextBox1.text))=$adTextBox1.text $adListBox1.ListIndex = $element $element = $adListBox1.ListCount endif next endselect EndFunction
Function ListBoxClicked() $adTextBox1.text = $adListBox1.Text $adTextBox1.SetFocus() $rc = SENDKEYS ("^{END}")
I am posting my script to try and make my intentions more clear. The red line is where my knowledge lacks (OK, one of the places my knowledge lakcs!) And I'll take a moment to say I really appreciate all the people who have the talent to creat UDFs and who post them in the UDF libraries for us newbies!
Code:
;NAME AddStudentToXeroxPrinterGroup.kix ;AUTHOR Jeremy Schubert ;PURPOSE Allows to add students to the Xerox printer group which will allow the students ;to print to that printer.
Break On $System = CreateObject("Kixtart.System")
If Not $System $nul= MessageBox("KiXforms Not Initiated. This Script Will Now Close.","Error",16) Quit() EndIf
HTMLInputBox("Please enter the user name of the student to be added to the Xerox Printer Group.", "Add Students To Xerox Printer Group","Names","SUBMIT","","","CANCEL","")
$usernames=names ;value of the box that shows in the HTMLInputBox function
For Each $username in $usernames " GroupAdd (CSSDSTU, GG047-XeroxPrinter, $username) Next
While $Form.Visible $nul = Execute($Form.DoEvents) Loop Exit 1
Function HTMLInputBox() - Displays an Input-Box via IE
; Function HTMLInputBox() - Displays an Input-box via IE ; ; Author: Steve O ; posted as UDF by NTDOC ; Posted in Beta forum - http://www.kixtart.org/ubbthreads/showthreaded.php?Cat=0&Number=77407 ; ; ACTION: Displays an Input-box that allows a user to input a string. This box is HTML based and ; uses the Internet Explorer Application object. ; ; SYNTAX: HTMLInputBox("HTML Message", OPTIONAL "Window Title","Default Value","Button Text","Text Color", ; "Background Color", "Alt Button Text","Alt Button Return Value") ; ; Version: 1.0 ; ; Date: Sep 27 2001 ; ; Date Revised: ; ; Revision Reason: ; ; PARAMETERS: ; HTML Message: The message for the Input Box. ex: What is your favorite color? ; Note: This can accept any HTML code, so go to town! Also Note: the tag is enabled, so if you want to do ; custom HTML, put as the first tag. ; Window Title: ( OPTIONAL ) The title of the HTML Input Box Window. If blank, defaults to "Question...". ; Default Value: ( OPTIONAL ) The default value for the box which will show when the box appears. ; If blank, defaults to blank. ; Button Text: ( OPTIONAL ) The text on the main button. If blank, default is "SUBMIT". ; Text Color: ( OPTIONAL ) The color of text on the input box. If blank, this defaults to black. ; Note: This can be overridden by including additional HTML tags in the HTML Message. ; Background Color: ( OPTIONAL ) The color of the background of the HTML form. Defaults to silver. ; Alt Button Text: ( OPTIONAL ) If this is specified, an alternate button will appear on the form and ; if clicked, the function will (by default) return "-1". This is useful as a "HELP" button, or ; for many other purposes. ; Alt Button Return Value: ( OPTIONAL ) If the Alt button is needed, and -1 is a potential legitimate ; return value for the main submit button, you can specify an alternate return value for the alternate button. ; ; REMARKS: ; This has been tested by the author on Win 98 and Win 2k machines. It should require at least IE 4.0 ; to function, however it does not check the IE version before executing. ; ; RETURNS: ; The string in the text box, or another value if the "Alternate button" is pressed. The alternate value ; defaults to -1, but can be changed by specifying the "Alt Button Return Value". ; ; Dependencies: IE, KiXtart 4.x ; ; EXAMPLE: ; HTMLInputBox("What is your favorite color?","Color Quiz","Red","Submit Me!","Black","Yellow","I don't know!!!") ; ; Source:
Function HTMLInputBox($L_Prompt, OPTIONAL $L_Title,$L_DefaultValue,$L_ButtonText,$L_TextColor,$L_BGColor,$L_AltButtonText,$L_AltButtonReturnValue) Dim $HTML, $AppIE, $SF If $L_Title = "" $L_Title = "Question..." EndIf
If $L_ButtonText = "" $L_ButtonText = "Submit" EndIf
If $L_AltButtonReturnValue = "" $L_AltButtonReturnValue = -1 EndIf
Select Case $L_TextColor = "Black" $L_TextColor = "000000" Case $L_TextColor = "Silver" $L_TextColor = "C0C0C0" Case $L_TextColor = "Gray" $L_TextColor = "808080" Case $L_TextColor = "White" $L_TextColor = "FFFFFF" Case $L_TextColor = "Maroon" $L_TextColor = "800000" Case $L_TextColor = "Red" $L_TextColor = "FF0000" Case $L_TextColor = "Purple" $L_TextColor = "800080" Case $L_TextColor = "Fuchsia" $L_TextColor = "FF00FF" Case $L_TextColor = "Green" $L_TextColor = "008000" Case $L_TextColor = "Lime" $L_TextColor = "00FF00" Case $L_TextColor = "Olive" $L_TextColor = "808000" Case $L_TextColor = "Yellow" $L_TextColor = "FFFF00" Case $L_TextColor = "Navy" $L_TextColor = "000080" Case $L_TextColor = "Blue" $L_TextColor = "0000FF" Case $L_TextColor = "Teal" $L_TextColor = "008080" Case $L_TextColor = "Aqua" $L_TextColor = "00FFFF" Case $L_TextColor = "" $L_TextColor = "000000" EndSelect
Select Case $L_BGColor = "Black" $L_BGColor = "000000" Case $L_BGColor = "Silver" $L_BGColor = "C0C0C0" Case $L_BGColor = "Gray" $L_BGColor = "808080" Case $L_BGColor = "White" $L_BGColor = "FFFFFF" Case $L_BGColor = "Maroon" $L_BGColor = "800000" Case $L_BGColor = "Red" $L_BGColor = "FF0000" Case $L_BGColor = "Purple" $L_BGColor = "800080" Case $L_BGColor = "Fuchsia" $L_BGColor = "FF00FF" Case $L_BGColor = "Green" $L_BGColor = "008000" Case $L_BGColor = "Lime" $L_BGColor = "00FF00" Case $L_BGColor = "Olive" $L_BGColor = "808000" Case $L_BGColor = "Yellow" $L_BGColor = "FFFF00" Case $L_BGColor = "Navy" $L_BGColor = "000080" Case $L_BGColor = "Blue" $L_BGColor = "0000FF" Case $L_BGColor = "Teal" $L_BGColor = "008080" Case $L_BGColor = "Aqua" $L_BGColor = "00FFFF" Case $L_BGColor = "" $L_BGColor = "C0C0C0" EndSelect
;Write the HTML code to the document $AppIE.document.write($HTML)
While $AppIE.busy <> 0 And @ERROR = 0 Loop
;Make IE visible and set focus $AppIE.visible = 1 $SF = SetFocus("about:blank - Microsoft Internet Explorer") $AppIE.document.GetElementById("Answer").focus
Dim $L_LastBoxValue,$L_LastBoxValueCache While $appIE.document.GetElementById("Submitted").value = 0 If $appIE.document.GetElementById("Submit").value = " " + $L_ButtonText + " " If $appIE.document.GetElementById("Answer").value <> "" $L_LastBoxValue = $appIE.document.GetElementById("Answer").value If $L_LastBoxValue <> "" $L_LastBoxValueCache = $L_LastBoxValue EndIf EndIf EndIf Loop
;NAME GroupAdd ; ;AUTHOR ??? ; ;ACTION Add's a object (user or group) to a group (global or local) ; ;SYNTAX GroupAdd(Target, Group, Object To add) ; ;PARAMETERS Target ; The Domain name or Workstation To work with. For faster workstation ; execution, include the Domain Name that the workstation is a meber of. ; ; "Kixtart/beanbag" would be working with the workstation Beanbag In the ; Kixtart domain ; ; Group ; The Group you want To add To ; ; Object To add ; This can be a local group or a userid, depending on what type of group ; the Group variable is. Always try To give the full name of the object. ; ; ;RETURNS @ERROR code ; ;REMARKS ADSI com object must be installed. ; ;EXAMPLES ;this adds the domain user "testuser" To the Global group "Domain Admins" ; $nul = groupadd("kixtart","Domain admins","testuser") ; ; ;this adds the user "testuser" In the domain "kixtart" To the local administrators ; ;group on the workstation beanbag ; $nul = Groupadd("kixtart/beanbag", "administrators", "kixtart\testuser") Function GroupAdd($Target, $Group, $ObjToAdd) Dim $target, $group, $OBJToAdd, $obj, $objhome
#169669 - 2006-10-2009:24 PMRe: Inputing users/groups into scripts
NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11634
Loc: Space
Well I've taken your code and used PostPrep to post it which attempts to allow certain html coding to be displayed.
Notice that you have mis-matched quotes which is why the syntax coloring is off on the post as well here.
I've added some comments and have changed some indenting.
Your HTMLInput UDF is rather large and I would really work on that as an individual UDF and make sure it works as expected in a self contained script until you know it is working the way you want it.
Basically review your code and remove the mis-matched quotes and remark or remove stuff that is not code you expect to operate as part of the script.
Thanks for the suggestions NTDOC. I check out your suggestions and put them into play when I test my script next week. I'll let you know how it goes. Just to let you know, the HTMKInputBox function isn't mine, it was written by Steve O. And where can I find more info on PressPost? Thanks,
_________________________
--- Bishop Grandin Technology Department 'Either we're on time, or we're late'