Page 1 of 1 1
Topic Options
#123124 - 2004-07-16 04:22 PM user is member of more then one group
Prs01blu Offline
Fresh Scripter

Registered: 2004-04-02
Posts: 15
Loc: Kitchener, ON
I'm looking to map users who belongs to more then one group. Server is 2K and the stations are XP PRO.
In a SELECT statement, only the first true condition will be processed. The flow of the script will then jump to the ENDSELECT statement, and continue. So I used IF INGROUP to search for user's membership and map the drives accordly. Again is mapping the first group of the array or none..any advice and /or good documentation
$Array = "mech", "mech_USR", "super", "test"
If InGroup ($Array, 1) = 1
; Use $Drive /Delete /Persistent
Use H: /DELETE
Use H:"\\anyserver\DATA\HOME\@USERID" /PERSISTENT
$LABELSTATUS.TEXT = "Mapping H: Drive..."
$PROGRESSSTATUS.VALUE = $PROGRESSSTATUS.VALUE + 1
Sleep 2
Use K: /DELETE
Use K: "\\anyserver\mech" /PERSISTENT
$LABELSTATUS.TEXT = "Mapping K: Drive..."
$PROGRESSSTATUS.VALUE = $PROGRESSSTATUS.VALUE + 0.5
Sleep 2
Use T: /DELETE
Use T: "\\anyserver\DATA\TEMP" /PERSISTENT
$LABELSTATUS.TEXT = "Mapping T: Drive..."
$PROGRESSSTATUS.VALUE = $PROGRESSSTATUS.VALUE + 0.5
Sleep 2
Use W: /DELETE
Use W: "\\anyserver\DATA\TEMPLATE" /PERSISTENT
$LABELSTATUS.TEXT = "Mapping W: Drive..."
$PROGRESSSTATUS.VALUE = $PROGRESSSTATUS.VALUE + 0.5
Sleep 2
EndIf
If InGroup("mech_USR") = 1
Use LPT2: "\\anyserver\mech_LASER" /PERSISTENT
If AddPrinterConnection ("\\anyserver\mech_LASER") = 0
SetDefaultPrinter ("\\anyserver\mech_LASER")
$LABELSTATUS.TEXT = "Mech_laser default on LPT2 ..."
EndIf

If InGroup("super") = 1
Use R: "\\anyserver\DATA\ACCNT\super" /PERSISTENT
$LABELSTATUS.TEXT = "Mapping R: Drive..."
$PROGRESSSTATUS.VALUE = $PROGRESSSTATUS.VALUE + 1
Sleep 2
Use LPT3: "\\anyserver\super" /PERSISTENT
EndIf

If InGroup("test")=1
Use P: "\\anyserver\DATA\ACCNT\test" /PERSISTENT
$LABELSTATUS.TEXT = "Mapping P: Drive..."
$PROGRESSSTATUS.VALUE = $PROGRESSSTATUS.VALUE + 1
Sleep 2
EndIf
thanks in advance for your time .

Top
#123125 - 2004-07-16 04:33 PM Re: user is member of more then one group
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
not really sure what you tried here:
Code:
$Array = "mech", "mech_USR", "super", "test"
If InGroup ($Array, 1) = 1


but think you were after:
Code:

If InGroup ("mech", "mech_USR", "super", "test")

_________________________
!

download KiXnet

Top
#123126 - 2004-07-16 04:49 PM Re: user is member of more then one group
Prs01blu Offline
Fresh Scripter

Registered: 2004-04-02
Posts: 15
Loc: Kitchener, ON
I see your point, but not all the users are members of all this groups..so, how can I write the script to map the drive letters, lets say..user X belongs to mech_usr, super, test and user Y belongs to mech and test. The mapping is done just for the first group in the script. The array thing is on the KiXtart manual
Top
#123127 - 2004-07-16 05:48 PM Re: user is member of more then one group
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
In your code, you supplied the MODE parm of '1' which means ALL.

Borrowing from the manual:
Quote:

Mode

Optional integer parameter indicating whether or not InGroup checks for group membership of one or all groups in the list (default = 0). Possible values:

0 InGroup checks for membership of ONE of the groups in the list (default)
1 InGroup checks for membership of ALL of the groups in the list



_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#123128 - 2004-07-16 06:40 PM Re: user is member of more then one group
Prs01blu Offline
Fresh Scripter

Registered: 2004-04-02
Posts: 15
Loc: Kitchener, ON
ok, correct me if I'm wrong.
1 Ingroup checks for membership of ALL of the groups in the list. Isn't that what I want to accomplish? ..to check to see in all this groups if the user is member or not and to map the drive and the printer depends of the group. When I run the script it maps just the first group in the list and skips the rest, works fine if the user is member of one group

Top
#123129 - 2004-07-16 07:21 PM Re: user is member of more then one group
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Make up your mind.

You said:
Quote:

but not all the users are members of all this groups




Now you are saying:
Quote:

1 Ingroup checks for membership of ALL of the groups in the list. Isn't that what I want to accomplish?




I cannot attest to what YOU want to accomplish if you contradict yourself.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#123130 - 2004-07-29 11:53 PM Re: user is member of more then one group
Prs01blu Offline
Fresh Scripter

Registered: 2004-04-02
Posts: 15
Loc: Kitchener, ON
ok ..I'm still having problems with mapping and INGROUP. mapping isnt done at all or is running fine for the first INGROUP group. If the "mech" group is in the first group the mapping is done just for them ..If I move "test" group in the first line of script just "tes"t group is mapped. If a user belongs to the both groups ,sometimes not mapping at all and sometimes just for one of the groups..any clues? ..
Top
#123131 - 2004-07-29 11:59 PM Re: user is member of more then one group
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Sounds like a program flow problem. Please post your code using the "CODE" tags. We can then see if the code is properly structured.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#123132 - 2004-07-30 12:15 AM Re: user is member of more then one group
Prs01blu Offline
Fresh Scripter

Registered: 2004-04-02
Posts: 15
Loc: Kitchener, ON
ok here is the part of the script starting with the network function
code starts here:
Code:

If InGroup ("mech") = 1
;Use $Drive /Delete /Persistent
Use H: /DELETE
Use H:"\\anyserver\DATA\HOME\@USERID" /PERSISTENT
$LABELSTATUS.TEXT = "Mapping H: Drive..."
$PROGRESSSTATUS.VALUE = $PROGRESSSTATUS.VALUE + 1
Sleep 2
Use K: /DELETE
Use K: "\\anyserver\mech" /PERSISTENT
$LABELSTATUS.TEXT = "Mapping K: Drive..."
$PROGRESSSTATUS.VALUE = $PROGRESSSTATUS.VALUE + 0.5
Sleep 2
Use T: /DELETE
Use T: "\\anyserver\DATA\TEMP" /PERSISTENT
$LABELSTATUS.TEXT = "Mapping T: Drive..."
$PROGRESSSTATUS.VALUE = $PROGRESSSTATUS.VALUE + 0.5
Sleep 2
Use W: /DELETE
Use W: "\\anyserver\DATA\TEMPLATE" /PERSISTENT
$LABELSTATUS.TEXT = "Mapping W: Drive..."
$PROGRESSSTATUS.VALUE = $PROGRESSSTATUS.VALUE + 0.5
Sleep 2
EndIf

If InGroup("mech_USR") = 1
Use LPT2: "\\anyserver\mech_LASER" /PERSISTENT
If AddPrinterConnection ("\\anyserver\mech_LASER") = 0
SetDefaultPrinter ("\\anyserver\mech_LASER")
$LABELSTATUS.TEXT = "Mech_laser default on LPT2 ..."
EndIf

If InGroup("super") = 1
Use R: "\\anyserver\DATA\ACCNT\super" /PERSISTENT
$LABELSTATUS.TEXT = "Mapping R: Drive..."
$PROGRESSSTATUS.VALUE = $PROGRESSSTATUS.VALUE + 1
Sleep 2
Use LPT3: "\\anyserver\super" /PERSISTENT
EndIf

If InGroup("test")=1
Use P: "\\anyserver\DATA\ACCNT\test" /PERSISTENT
$LABELSTATUS.TEXT = "Mapping P: Drive..."
$PROGRESSSTATUS.VALUE = $PROGRESSSTATUS.VALUE + 1
Sleep 2
EndIf


END of Code
..I have a variety of group membership ..some users belongs just to "super" or "super" and "testers" or "testers" and "mech_usr" or just "mech_usr".. Mapping never worked for any users

Added CODE tags - H. Bullock


Edited by Prs01blu (2004-07-30 12:50 AM)

Top
#123133 - 2004-07-30 12:23 AM Re: user is member of more then one group
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
It is good programming practice to properly indent your code so that is is easier to read and debug. Please properly format your code. I have added the proper code tags. You can edit your post and replace the code when formatted.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#123134 - 2004-07-30 02:49 AM Re: user is member of more then one group
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Are there any eventlog errors that might point to an AD misconfiguration preventing the user to perform group membership lookups?
_________________________
There are two types of vessels, submarines and targets.

Top
#123135 - 2004-07-30 02:59 AM Re: user is member of more then one group
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Are these global or local groups? Have you tried using the domain or server name before the group name? Reviewing your code now.

Edited by Howard Bullock (2004-07-30 03:02 AM)
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#123136 - 2004-07-30 03:02 AM Re: user is member of more then one group
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Why map drives as persistent if they are mapped on every logon? If you map with the /persistent switch, you also need to use the /persistent switch to delete.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#123137 - 2004-07-30 03:08 AM Re: user is member of more then one group
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I do not see anything malformed with this code you posted. I would suggest that you include "ELSE" statements with logging to verify if the ingroup actually executes or not. There may be a logic error or missing quote elsewhere in the program that somehow affects this block.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#123138 - 2004-07-30 03:10 AM Re: user is member of more then one group
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I was looking at that too, but failed to comment. I agree that the /PERSISTENT switch should be removed from the "USE" statement but should be permanently added to the "USE /DELETE" in case a user remaps a drive to another location.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#123139 - 2004-07-30 03:17 AM Re: user is member of more then one group
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I don't believe that is your entire code. You are obviously jumping around to update your progressbar but you don't show how in your posted code.

Strip the code down to the bare essentials and run it as a separate test script in debug.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#123140 - 2004-07-30 03:04 PM Re: user is member of more then one group
Prs01blu Offline
Fresh Scripter

Registered: 2004-04-02
Posts: 15
Loc: Kitchener, ON
OOOPPSS!!.. I brush up my script one more time and yes, always-small details count a lot…editing the post and properly indent the script code.
To respond to everyone:
1.-yes I agree with /delete and /persistent and I'll make the changes right away.
2.-the entire logon script was running ok, but mapping was always skipped and logon was completed with no error messages. They are successfully logged on to domain and if you try to map the drives, mapping is successfully done.
3.-my progress bar function is part of the script and basically gives you an idea of how the logon script progress until is done.
OK. So I realized that I had in my script a line here is the code:

Code:
If InGroup("mech_USR") = 1


Use LPT2: "\\anyserver\mech_LASER" /PERSISTENT

If AddPrinterConnection ("\\anyserver\mech_LASER") = 0
SetDefaultPrinter ("\\anyserver\mech_LASER")
$LABELSTATUS.TEXT = "Mech_laser default on LPT2 ..."

EndIf




IF Addprinterconection () with no ENDIF . I made the changes and now the mapping it is working fine .
I posted so many details just in case somebody has the same or similar problem..

Thanks Howard, Sealeopard, and Les for you help and advice. No so confused any more!


Edited by Prs01blu (2004-07-30 03:06 PM)

Top
#123141 - 2004-07-30 09:21 PM Re: user is member of more then one group
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Sorry, dude. I looked over you posted code and missed the missing ENDIF also. It is plain as day just above.
_________________________
Home page: http://www.kixhelp.com/hb/

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 259 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.07 seconds in which 0.024 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