Page 1 of 1 1
Topic Options
#126984 - 2004-09-23 08:44 AM INGROUP fails when group belongs to other group
Henry Offline
Fresh Scripter

Registered: 2004-07-27
Posts: 6
Hi

I found this GREAT kix code which use group.ini file to connect drives to specified groups members.

Unfortunately it wonīt detect "sub group members" when some AD group belongs to other group and
this other group has members.

Also I couldnīt find correct way to solve problems if share name contain $ or - marks in it name.
(like \\server\backup$ or \\server\pdf-documents) Whole script will terminate to error.

Gurus.. please send some advice to correct this script =)
Code:

$logonserver = "Server1"
? "Connecting network drives by your group membership..."
? ""
$sGroupINI = "\\$logonserver\netlogon\kix422\groups.ini"
For Each $group in Split(ReadProfileString($sGroupINI,'',''),Chr(10))
If $group AND InGroup($group)
For Each $drive In Split(ReadProfileString($sGroupINI,$group,''),Chr(10))
If $drive
$resource=readprofilestring($sGroupINI,$group,$drive)
$rc=execute('$$resource='+$resource)
Use $drive+':' /delete /persistent
"Mapping drive "+$drive+": to "+$resource
Use $drive+':' $resource
IF @ERROR <> 0
$FAILDESCRIPTION = "@error / @serror: Letter $drive to $resource"
$FAILNAME = "Connect drives by groups.ini failed"
CALL "\\$logonserver\netlogon\kix422\error_debug_hidden.kix"
COLOR R+/N
" ***ERROR***"
? "["+@ERROR+"] "+@SERROR ?
COLOR W/N
Else
" OK" ?
EndIf
EndIf
Next
EndIf
Next


Group.ini file looks like this..
Code:

[Domain Users]
V= \\server1\share1
X= \\server2\share2

[Quality Users]
T= \\server3\share1
R= \\server4\share2


Regards,
Henry


Edited by Henry (2004-09-23 10:05 AM)

Top
#126985 - 2004-09-23 09:46 AM Re: INGROUP fails when group belongs to other group
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Please post you code in "code" tags - it's a devil to read if you don't.

To fix your aborting problem when the share name contains special characters, change this line:
Code:
$rc=execute('$$resource='+$resource)



to this:
Code:
$rc=execute('$$resource="'+$resource+'"')



The problem is that the bare share name will be interpreted as KiXtart script code, so you need to protect it with speech marks.

Top
#126986 - 2004-09-23 11:25 AM Re: INGROUP fails when group belongs to other grou
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
why is the execute line in here???
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#126987 - 2004-09-23 11:29 AM Re: INGROUP fails when group belongs to other grou
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
To expand variables, macros and environment variables present in the path e.g. H=\\HOMESHARES\@USERID would expand to the users name.

Not useful in this case as none of the paths need expanding, but probably used by the original coder that the script was taken from.

Top
#126988 - 2004-09-24 12:29 AM Re: INGROUP fails when group belongs to other grou
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Got it Richard,

thanks for the explanation.
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.077 seconds in which 0.031 seconds were spent on a total of 12 queries. Zlib compression enabled.

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