#69235 - 2002-08-20 11:14 PM
Arrays and Menu's
|
jamen
Fresh Scripter
Registered: 2002-05-31
Posts: 13
|
I'm not looking for code or anything, just more logic on how to create a menu like this:
Please select from the following: 1 Item 1 2 Item 2 3 Item 3 Selection:
The problem is that the menu should search through multiple AD groups, and users are assigned to more than one AD group. The Items are different shares that will be mapped. The only items I want listed are items that match their AD group membership. Could be 4,5,6, up to 10 items.
I only want people to have 2 mapped drives. The drive they select from their memberships and their homeshare.
If I need more explanation, please let me know.
Any info on how to do something like this would be greatly appreciated... Thanks! Ben
|
Top
|
|
|
|
#69237 - 2002-08-21 12:17 AM
Re: Arrays and Menu's
|
jamen
Fresh Scripter
Registered: 2002-05-31
Posts: 13
|
If I use an ENUMGROUP, how could I extract the groups that the user is a member of to display? Does it keep a default array (like perl $_) of groups that the user is in? I guess I don't follow on what to do afterwards....
|
Top
|
|
|
|
#69239 - 2002-08-21 10:30 PM
Re: Arrays and Menu's
|
jamen
Fresh Scripter
Registered: 2002-05-31
Posts: 13
|
Okay I used the lines:
$=-1 do $=$+1 $f=enumgroup($) ? $f until $f="" sleep 5
It displays the memberships, now I need to move them into an array... Would something like this work to place it into an array?
$=-1 do $=$+1 $f=enumgroup($) ? $f ;place memberships for user into array $array[$index]=$f $index=$index + 1 until $f=""
From there I would need to place the array into a menu selection. Am I on the right train of thought, or am I way off base??? As you can tell I'm not a programmer, but I like to try every now and then.
|
Top
|
|
|
|
#69242 - 2002-08-22 12:17 AM
Re: Arrays and Menu's
|
jamen
Fresh Scripter
Registered: 2002-05-31
Posts: 13
|
We want to limit students to have one homeshare and one mapped drive to the class that they will be working on when logged in. Just to restrict the user/student. They will have to choose a class every time they log in. This wasn't my idea, but my boss wants it this way. Example: BeginningKeyboarding is a AD Group, \\Server\BeginningKeyboarding is a share (same name as AD group). What I would like to do is have BeginningKeyboarding a menu selection and then have a mapping statement like: use v: \\Server\$classselection instead of creating 50 if statements for each class (like if $selectedclass = 3 then use v: \\server\begkey). Sorry if I am not explaining this very well. I thought about creating an array like: $classarray = BegKey CompSci InfoSys ect.... and then splitting them by " ", but I'm not sure if that's what I'm looking for or not.... Any help is greatly appreciated along with comments for the code so I can learn with it instead of just copying and pasting.... Thanks!
Ben
|
Top
|
|
|
|
#69244 - 2002-08-22 01:22 AM
Re: Arrays and Menu's
|
jamen
Fresh Scripter
Registered: 2002-05-31
Posts: 13
|
I do have it setup so that the group names are exactly the same as the class shares. I would like to do it with one loop. I don't follow you on how to create the ini file or how to set it up this way... Could you explain this a little further?
|
Top
|
|
|
|
#69245 - 2002-08-22 03:36 AM
Re: Arrays and Menu's
|
Sealeopard
KiX Master
Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
|
To recap:
1) You have students taking one or more classes (excludes arranging users in groups, since user might be in multiple groups) 2) Each student will only get the appropriate class mapping 3) Each student will get the homeshare 4) Computers can be used for more than one class (would exclude arranging computers in groups in AD)
Solution: 1) Create hidden shares for the homedrives, preferably based on the username. Thus, you'd end up with local directories on a server like D:\USERS\USER1 and hidden share USER1$ D:\USERS\USER2 and hidden share USER2$
2) Create hidden shares for the class directories like E:\CLASSES\BEGINNINGKEYBOARDING with hidden share BEGINNINGKEYBOARDING$ E:\CLASSES\HACKING101 with hidden share HACKING101$
3) Create a CLASSES.INI file in the same directory where the login script is. Format: [CLASSES] BEGINNINGKEYBOARDING=\\server1\beginningkeyboarding$ HACKING101=\\server2\hacking101$
Basically, you assign the share to the appropriate classname
Then you can use READPROFILESTRING to read in the list of classes. Have the student choose a class and then read the drive mapping for that class. Basic code would look like this:
code:
$classes=readprofilestring(@scriptdir+'\classes.ini','Classes','') $classes=split($classes,chr(10)) $selection=-1 do cls for $class=0 to ubound($classes) ? ''+$class+') '+$classes[$class] next gets $selection $selection=val($selection) until $selection>=0 and $selection<=ubound($classes) $class=$classes[$selection] $classmapping=readprofilestring(@scriptdir+'\classes.ini','Classes',$class)
net use H: $classmapping if @error ? 'Error mapping drive H: to '+$classmapping ? 'Error code: '+@ERROR+' - '+@SERROR endif
$homeshare='\\server\'+@USERID+'$$' net use I: $homeshare if @error ? 'Error mapping drive I: to '+$homeshare ? 'Error code: '+@ERROR+' - '+@SERROR endif
[ 22. August 2002, 03:37: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.
|
Top
|
|
|
|
#69246 - 2002-08-22 11:32 PM
Re: Arrays and Menu's
|
jamen
Fresh Scripter
Registered: 2002-05-31
Posts: 13
|
I used that and it's close to what I want... But not exactly. That gives me a list of all 128 classes and my selection line prompt is: 129) I think I can figure out the prompt once I completely understand the code. But what I want is to display only the classes that the student is a member too. The AD groups are named the same as the share names. How would I display just those groups instead of the whole file?
|
Top
|
|
|
|
#69251 - 2002-09-11 02:15 AM
Re: Arrays and Menu's
|
jamen
Fresh Scripter
Registered: 2002-05-31
Posts: 13
|
Finally came up with a solution... Couldn't have done it with all of your guy's help!! Thanks, I owe you all a round of beers, no make it two...
Ben
code:
use v: /delete use w: @homeshr
if exist(c:\temp\temporary.txt) del "c:\temp\temporary.txt" endif if exist(c:\temp\classes.ini) del "c:\temp\classes.ini" endif if exist(c:\temp\remove.txt) del "c:\temp\remove.txt" endif
IF @inwin = 1 Sendkeys("~{TAB}") ENDIF
Open(1,"c:\temp\temporary.txt",5) Open(2,"c:\temp\classes.ini",5) Open(3,"c:\temp\remove.txt",5)
writeline(2,"[classes]" + Chr(13)+ Chr(10))
;This part writes all of the groups into a file $groupcount=0 do redim preserve $groups[$groupcount] $group=ENUMGROUP($groupcount) $groups[$groupcount]=$group writeline(1,$group + Chr(13) + Chr(10)) $groupcount=$groupcount+1 until len($group)=0
close(1) close(2) close(3)
open(1,"c:\temp\temporary.txt",2) open(3,"c:\temp\remove.txt",4)
$remdomuser="xxx\Domain Users" $remdomuserlen=Len($remdomuser) $remdomstud="xxx\Students_Global" $remdomstudlen=len($remdomstud) $deleteme=Readline(1) while @ERROR=0 if Left($deleteme,$remdomuserlen)=$remdomuser $remdomuser="trash" writeline(3,$remdomuser + Chr(13) + Chr(10)) $deleteme=Readline(1) endif if Left($deleteme,$remdomstudlen)=$remdomstud $remdomstud="trash" writeline(3,$remdomstud + Chr(13) + Chr(10)) $deleteme=Readline(1) else writeline(3,$deleteme + Chr(13) + Chr(10)) $deleteme=Readline(1) endif loop close(1) close(3) ;This is my test area below
Open(3,"c:\temp\remove.txt",2) Open(2,"c:\temp\classes.ini",4)
$dom="xxxxxxx\" $domlen=Len($dom) $strip=Readline(3) while @ERROR = 0 If Left($strip,$domlen)=$dom $strip=SubStr($strip,$domlen+1) "Group stripped of domain = " ? $strip writeline(2,$strip + "=\\Server\"+ $strip + Chr(13) + Chr(10)) $strip=ReadLine(3) ? $strip Else $strip=ReadLine(3) ? $strip Endif loop close(3) close(2) ;This is my test area above
;This part reads and displays a menu Open(2,"c:\temp\classes.ini",2) $classes=readprofilestring("c:\temp\classes.ini",'Classes','') $classes=split($classes,chr(10)) $selection=-1 do cls for $class=1 to ubound($classes) ? ''+$class+') '+$classes[$class-1] next " Type in a class number or press enter for none. If you select the wrong class, you will have to log out and log back in. Enter Selection : " gets $selection $selection=val($selection) until $selection>=0 and $selection=ubound($classes) $selection=$selection - 1 $class=$classes[$selection] $classmapping=readprofilestring(@scriptdir+'\classes.ini','Classes',$class) use v: $classmapping if @error ? 'Error mapping drive v: to '+$classmapping ? 'Error code: '+@ERROR+' - '+@SERROR endif close(1) close(2) del "c:\temp\temporary.txt" del "c:\temp\classes.ini" del "c:\temp\remove.txt"
[Moderator (Sealeopard)]: Fixed incorrect code tags [ 11. September 2002, 17:41: Message edited by: sealeopard ]
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 466 anonymous users online.
|
|
|