Page 1 of 1 1
Topic Options
#176308 - 2007-05-16 03:02 PM using an array to map drives based on group membership
Pieman Offline
Fresh Scripter

Registered: 2002-08-20
Posts: 29
being a complete ejit & not having the time or to be honest the necessity to do much scripting, I am wondering if someone can answer my question.

Is it possible to use InGroup statements within an array to process and map multiple network drives based upon group membership, if so how in the hell would you go about this, at the moment (due to my very limited Kix knowledge) I am forced to use a load of InGroup statements to check to see if the user is a member of each group... surely there has to be a more efficient way of scripting this
_________________________
It takes a human hours to fcuk up what a computer can do in seconds...

Top
#176309 - 2007-05-16 03:12 PM Re: using an array to map drives based on group membership [Re: Pieman]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Hi Pieman,
I am sure there are plenty of people that can help you out, if you post what you have for InGroup() stuff we can better help you.
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#176310 - 2007-05-16 03:25 PM Re: using an array to map drives based on group membership [Re: Benny69]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Here's the basic concept for individually checking multiple group memberships.

 Code:
$Share=\\server\share
$Drive=F:
$Groups='Grp1','Grp2','Grp3'


$OK = 0
For Each $Group in $Groups	; enumerate each group in the array
  If InGroup($Group)		; if user is a member of any one
    $OK = 1			; then it is OK to map this resource
  EndIf
Next

If $OK
  ;Use $Drive $Share
  'Mapping ' $Share ' to ' $Drive ?	; message for testing
EndIf


This is wrapped in a bigger loop, processing each of many share/drive/group specifications, possibly reading them from an INI file.

Keep in mind that InGroup() can check multiple groups, as in Ingroup('Grp1','Grp2','Grp3'). This will return true if the user is a member of ANY group in the list.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#176311 - 2007-05-16 03:33 PM Re: using an array to map drives based on group membership [Re: Benny69]
Pieman Offline
Fresh Scripter

Registered: 2002-08-20
Posts: 29
OK, Here is a small snipet of the ingroup statements, there are aleast 20+ group and probably just as many shares so as you can imagine the code gets quite long and repetative... remember I am an ejit with this so don't laugh at the code at the moment it does the job...

 Code:
 
Select
Case InGroup("finance_gbl")
Use F: "\\server_name\share"
If @ERROR
$message = MessageBox('Error: '+@ERROR+'-'+@SERROR, 'Error Mapping Finance drive',48)
EndIf
Case InGroup("finance ro_gbl")
Use F: "\\server_name\share"
If @ERROR
$message = MessageBox('Error: '+@ERROR+'-'+@SERROR, 'Error Mapping Finance drive',48)
EndIf
EndSelect

Select
Case InGroup("Design_gbl")
Use G: "\\server_name\share"
If @ERROR
$message = MessageBox('Error: '+@ERROR+'-'+@SERROR, 'Error Mapping Design drive',48)
EndIf
Case InGroup("Design ro_gbl")
Use G: "\\server_name\share"
If @ERROR
$message = MessageBox('Error: '+@ERROR+'-'+@SERROR, 'Error Mapping Design drive',48)
EndIf
Case InGroup("TCADRD_gbl")
Use G: "\\server_name\share"
If @ERROR
$message = MessageBox('Error: '+@ERROR+'-'+@SERROR, 'Error Mapping Design drive',48)
EndIf
EndSelect

 
_________________________
It takes a human hours to fcuk up what a computer can do in seconds...

Top
#176312 - 2007-05-16 03:36 PM Re: using an array to map drives based on group membership [Re: Glenn Barnas]
Pieman Offline
Fresh Scripter

Registered: 2002-08-20
Posts: 29
Thnaks Glenn,

However each share would map to a different drive, so surely I would need to check that the user is a member of each group and map a drive for the respective share, how would this be accomplished?
_________________________
It takes a human hours to fcuk up what a computer can do in seconds...

Top
#176313 - 2007-05-16 03:55 PM Re: using an array to map drives based on group membership [Re: Pieman]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
give this a spin;
 Code:
$Groups = "finance_gbl","finance ro_gbl"
$Drive = F:
$Shares = "\\server_name\share","\\server_name\share"

CheckGroups($Groups,$Drive,$Shares)

$Groups = "Design_gbl","Design ro_gbl","TCADRD_gbl"
$Drive = G:
$Shares = "\\server_name\share","\\server_name\share","\\server_name\share"

CheckGroups($Groups,$Drive,$Shares)

Function CheckGroups($Groups,$Drive,$Shares)
	$Index = 0
	For Each $Group in $Groups
		If InGroup($Group)
			Use $Drive $Share[$Index]
			If @ERROR
				$Msg = MessageBox('Error: '+@ERROR+'-'+@SERROR, 'Error Mapping '+$Drive+' '+$Share[$Index]+' in '+$Group,48)
			EndIf
		EndIf
		$Index = $Index+1
	Next
EndFunction



Edited by Benny69 (2007-05-16 04:02 PM)
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#176314 - 2007-05-16 03:58 PM Re: using an array to map drives based on group membership [Re: Benny69]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
I just modified the code i just posted, thought it needed trimmed down a little.
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#176315 - 2007-05-16 04:08 PM Re: using an array to map drives based on group membership [Re: Benny69]
Pieman Offline
Fresh Scripter

Registered: 2002-08-20
Posts: 29
Benny your a superstar, I'll give it a go to make sure that I understand what it's doing.

Thanks everyone, this board continues to impress me with the help provided and the speed that everyone responds...
_________________________
It takes a human hours to fcuk up what a computer can do in seconds...

Top
#176324 - 2007-05-16 11:26 PM Re: using an array to map drives based on group membership [Re: Pieman]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Thnaks?? You're "lewcome", I suppose. ;\)

Download the login script from my web site and give it a whirl - just define it for a test user and see how dynamic mapping and even path rewriting work. The zip file has a pretty detaild Word doc and many examples to get you started. (path rewriting allows changing the share path info based on group, OU, or user info.)

Even if you don't use the script as is, you can see how the logic works. I have one drive map routine and handle thousands of users and dozens of shares with this script. I have used this script at all of my clients in the past without modification, so I'm pretty confident it can handle your needs. \:\)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


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

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

Generated in 0.073 seconds in which 0.03 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