Page 1 of 1 1
Topic Options
#189408 - 08/09/03 11:04 PM InGroup function not working consistently
Georges_K Offline
Getting the hang of it

Registered: 05/02/17
Posts: 83
Loc: Chino, CA
Hello experts,

I'm dealing with a problem with the InGroup function that popped out of nowhere.

I have users that essentially belong to 2 groups:
103-AllStudents and 103-Grade 9 (10, 11, 12)

I have a simple

 Code:
Select 
   Case InGroup("103-AllStudents") AND InGroup("103-Grade 9") 
....
EndSelect


The problem is that my case statement fails consistently when checking for 103-Grade 9 ... and is successful consistently on 103-AllStudents. (it also fails on 103-Grade 10, 103-Grade 11, 103-Grade 12. Mind you, it only fails on some accounts, but not others.

I have even tried it a simple script with just the If InGroup statement, so that it's isolated, and ran it manually from the console, and got the same result.

I have tried it the same thing with KIX32.exe version 4.52.0.0 and 4.60.0.0 and I got the same result.
I have checked the Logon Server @LSERVER and set l to make sure that I'm querying the user in AD that has all these group memberships. for some reason, whatever I do, I can't seem to get it to read that group.

This used to work... but now, and for whatever reason, it stopped working. any ideas??

Thanks in advance for your help!

Update:
I'm starting to think that this may have something to do with the tokencache. When I do an If InGroup , and query the group that the user USED to be a member of, I get a positive result. I have tried to clear the tokencache (kix32 /f) . but that didn't make a difference. Am I on the right track? is there something else that I need to be looking at?

Update:
If I do InGroup("103-Grade 10") the group is found, but if I do
InGroup('"' + $SchoolCode + '-Grade ' + $grade + '"') where I verified that the value of$SchoolCode is 103 and the value of grade is 10 , it doesn't work.

So it seems that at this point it's no longer a token cache issue, but something related to the way the variables are resolving (perhaps something to do with the space... since the following is working: InGroup($SchoolCode + "-All-Students")

I thought that by writing the group in the quotes (as above) should resolve the space issue... am I missing something?




Edited by Georges_K (08/09/03 11:53 PM)
_________________________
Network Specialist
Chino Unified School District

Top
#189411 - 08/09/04 12:35 AM Re: InGroup function not working consistently [Re: Georges_K]
Björn Offline
Korg Regular
*****

Registered: 05/12/07
Posts: 950
Loc: Stockholm, Sweden.
Yo, try changing your select statement to something in the lines of the command reference :
 Code:
IF INGROUP("Developers", "Testers", 1) = 1

    ? "Member of Developers AND Testers group"

ENDIF


Edited by Björn (08/09/04 12:35 AM)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#189415 - 08/09/04 12:58 AM Re: InGroup function not working consistently [Re: Björn]
Georges_K Offline
Getting the hang of it

Registered: 05/02/17
Posts: 83
Loc: Chino, CA
Björn, you're the man!
I'm not sure why it suddenly decided to stop working in the other format though, it was working for months.... I changed the syntax to what you suggested, and it worked like a charm... so weird!

Thank you very much, I appreciate your help!
_________________________
Network Specialist
Chino Unified School District

Top
#189416 - 08/09/04 01:01 AM Re: InGroup function not working consistently [Re: Georges_K]
Björn Offline
Korg Regular
*****

Registered: 05/12/07
Posts: 950
Loc: Stockholm, Sweden.
Nemas problemas :). Glad to help. Good luck, and don't ponder on questions to long, ppl are here to help \:\)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#189423 - 08/09/04 02:37 AM Re: InGroup function not working consistently [Re: Georges_K]
Glenn Barnas Moderator Offline
KiX Supporter
*****

Registered: 03/01/28
Posts: 4211
Loc: New Jersey
This statement is buggered:
 Code:
InGroup('"' + $SchoolCode + '-Grade ' + $grade + '"')

Better format would be
 Code:
$Tmp = $SchoolCode + '-Grade ' + $grade
'Checking ' $Tmp ?
If InGroup($Tmp)
; do stuff

You were making the quotes part of the group name, which is not correct. Just like command strings, building complex names or paths into a temp var allows you to display some debug info & be sure of what you're putting together.

Glenn
_________________________

Actually I am a Rocket Scientist! \:D

Top
#189425 - 08/09/04 03:10 AM Re: InGroup function not working consistently [Re: Glenn Barnas]
Georges_K Offline
Getting the hang of it

Registered: 05/02/17
Posts: 83
Loc: Chino, CA
Glenn,

Thanks for your input. Initially, my thought was exactly like yours (I had ommitted the quotes, until I noticed things weren't working that way.
I did have a method to my madness though \:\) ... I actually wasn't sure whether the InGroup function will recognize that group name which has a space in it as one entity, hence, my inclusion of the quotes, so that the resulting variable within the InGroup function ends up with quotes.

What you suggested, and please correct me if I'm wrong,

 Code:
$SchoolCode + '-Grade ' + $grade

will result in:
 Code:
InGroup(103-Grade 9)

and
 Code:
'"' + $SchoolCode + '-Grade ' + $grade + '"'

will result in:
 Code:
InGroup("103-Grade 9")

which in this case (a space in the group name) may be more appropriate... am I way off track?


Edited by Georges_K (08/09/04 03:12 AM)
_________________________
Network Specialist
Chino Unified School District

Top
#189426 - 08/09/04 03:18 AM Re: InGroup function not working consistently [Re: Georges_K]
Allen Moderator Offline
KiX Supporter
*****

Registered: 03/04/19
Posts: 4261
Loc: USA
Try this

'' + $SchoolCode + '-Grade ' + $grade

Kixtart thinks it should do math on this because because $schoolcode is a number. Putting the QuoteQuote will make it become a string.

Top
#189428 - 08/09/04 03:32 AM Re: InGroup function not working consistently [Re: Allen]
Glenn Barnas Moderator Offline
KiX Supporter
*****

Registered: 03/01/28
Posts: 4211
Loc: New Jersey
Allen's right (I missed that, was focused on the incorrect quotes)

Note that his example is not a double quote, but a pair of single quotes! It's a shortcut to CStr($SchoolCode) that works well, but isn't as obvious.

Also, if you build the group name, as I suggested, the quotes no longer become necessary (other than the leading '' trick, or using CStr() ) since the entire variable - spaces and all - is treated as a single entity. Thus
 Code:
$Tmp = CStr($SchoolCode) + '-Grade ' + $grade
'Checking ' $Tmp ?
If InGroup($Tmp)


Glenn
_________________________

Actually I am a Rocket Scientist! \:D

Top
#189429 - 08/09/04 04:20 AM Re: InGroup function not working consistently [Re: Glenn Barnas]
Georges_K Offline
Getting the hang of it

Registered: 05/02/17
Posts: 83
Loc: Chino, CA
Ah... I get it.. I actually had gathered pieces of this from several other posts... but now it's clear. the CStr piece was especially enlightening as I hadn't thought of that.
By the way, my response wasn't to argue that I was right, but merely trying to clarify what was wrong with the way I had it, mostly for future reference. Now that I look at the few different methods that you guys suggested, I think I'll use that instead ... it's also much simpler that way. Having a tons of quotes can get a bit confusing \:\)

I do appreciate you guys taking the time to explain this though. It was very helpful!!

Cheers!
_________________________
Network Specialist
Chino Unified School District

Top
#189539 - 08/09/08 06:01 PM Re: InGroup function not working consistently [Re: Georges_K]
KSDadGuy Offline
Just in Town

Registered: 08/09/02
Posts: 4
Loc: Kansas
Hello, my name is Jim Malay and I am pretty new to Kixtart and am having a problem in mapping drives. We only have five groups to test through and and the code I am using seems to find each group properly, but it does not map one of the drives. The drive not being mapped is T for Teachers. This is for the Staff groups (EW, AD & MS) Here is the if-then-else-if construct I am using. If I'm am just being stupid and not doing something correctly in my code, please let me know. Thanks in advance. Jim
 Code:
; The H drive mapping is for home shares
; The Q drive mapping is for shared application
; The T drive is for a shared Teacher area
; The main mapping for a printer will be SPSLAB
; EW_Staff printer mapping will be SPSEWP
; MS_Staff printer mapping will be SPSMSP
; AD_Staff printer mapping will be SPSADP
; Alternate printer mapping will be SPSTLP
;

CLS

IF INGROUP("IT_DEPT")
        SETDEFAULTPRINTER (\\SPSFP1\SPSLAB)
        USE H: "\\SPSFP1\@USERID$$"
        USE N: "\\SPSFP1\NTADMINS$$"
        USE Q: "\\SPSFP1\APPS"
ELSE
 IF INGROUP("MS_Staff")
        SETDEFAULTPRINTER (\\SPSFP1\SPSMSP)
	USE LPT1: "\\SPSFP1\SPSMSP"
        USE H: "\\SPSFP1\@USERID$$"
        USE Q: "\\SPSFP1\APPS"
        USE T: "\\SPSFP1\TEACHERS$$"
 ELSE
  IF INGROUP("EW_Staff")     
        SETDEFAULTPRINTER (\\SPSFP1\SPSEWP)
	USE LPT1: "\\SPSFP1\SPSMSP"
        USE H: "\\SPSFP1\@USERID$$"
        USE Q: "\\SPSFP1\APPS"
        USE T: "\\SPSFP1\TEACHERS$$"
  ELSE
   IF INGROUP("AD_Staff")
	USE LPT1: "\\SPSFP1\SPSLAB"
        USE H: "\\SPSFP1\@USERID$$"
        USE Q: "\\SPSFP1\APPS"
        USE T: "\\SPSFP1\TEACHERS$$"
   ELSE
        SETDEFAULTPRINTER (\\SPSFP1\SPSLAB)
        USE H: "\\SPSFP1\@USERID$$"
        USE Q: "\\SPSFP1\APPS"
   ENDIF 
  ENDIF
 ENDIF
ENDIF

EXIT


Edited by Glenn Barnas (08/09/08 09:09 PM)
Edit Reason: Code Tags & formatting

Top
#189545 - 08/09/08 09:13 PM Re: InGroup function not working consistently [Re: KSDadGuy]
Glenn Barnas Moderator Offline
KiX Supporter
*****

Registered: 03/01/28
Posts: 4211
Loc: New Jersey
Welcome to KORG. In the future, please don't hijack a thread - simply start your own. It's easier to manage things that way.

Else-If is not a valid Kix construct. Take a look at the reformatted code above to see how the If/Else line up.

Read the manual about the Select / Case / EndSelect statement and rewrite your code with a Select at the top, EndSelect at the bottom, and replace each IF with a Case (and remove the Else and EndIf statements).
Select/Case is like a multiple IF, where only the first valid condition is processed. Give that a try and report back if you need further assistance.

Glenn
_________________________

Actually I am a Rocket Scientist! \:D

Top
#189546 - 08/09/08 09:18 PM Re: InGroup function not working consistently [Re: KSDadGuy]
Gargoyle Offline
MM club member
*****

Registered: 04/03/09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Try it this way:

 Code:
$rc = SetOption("NoVarsInStrings","ON")
$rc = SetOption("NoMacrosInStrings","ON")

Select
  Case InGroup ("IT_DEPT)
   SETDEFAULTPRINTER (\\SPSFP1\SPSLAB)
   USE H: "\\SPSFP1\"+@USERID+"$"
   USE N: "\\SPSFP1\NTADMINS$"
   USE Q: "\\SPSFP1\APPS"
  Case Ingroup ("MS_STAFF")
   SETDEFAULTPRINTER (\\SPSFP1\SPSMSP)
   USE LPT1: "\\SPSFP1\SPSMSP"
   USE H: "\\SPSFP1\"+@USERID+"$"
   USE Q: "\\SPSFP1\APPS"
   USE T: "\\SPSFP1\TEACHERS$"
  Case Ingroup ("EW_STAFF"
   SETDEFAULTPRINTER (\\SPSFP1\SPSEWP)
   USE LPT1: "\\SPSFP1\SPSMSP"
   USE H: "\\SPSFP1\"+@USERID+"$"
   USE Q: "\\SPSFP1\APPS"
   USE T: "\\SPSFP1\TEACHERS$"
  Case Ingroup ("AD_Staff")
   USE LPT1: "\\SPSFP1\SPSLAB"
   USE H: "\\SPSFP1\"+@USERID+"$"
   USE Q: "\\SPSFP1\APPS"
   USE T: "\\SPSFP1\TEACHERS$"
  Case 1
   SETDEFAULTPRINTER (\\SPSFP1\SPSLAB)
   USE H: "\\SPSFP1\"+@USERID+"$"
   USE Q: "\\SPSFP1\APPS"
EndSelect]
_________________________
Today is the tomorrow you worried about yesterday.

Top
#189559 - 08/09/09 08:56 PM Re: InGroup function not working consistently [Re: Gargoyle]
KSDadGuy Offline
Just in Town

Registered: 08/09/02
Posts: 4
Loc: Kansas
Gargoyle,

Thanks for the quick reply. You're right in my mistake about not starting my own thread. Please chalk it up to being a newbie. I will be more careful in the future

KSDadGuy

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Chris S., Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
3 registered (BradV, AndrewRoom, Arend_) and 147 anonymous users online.
Newest Members
AndrewRoom, 000Raph000, curkus, Ken_Sumrall, Keris2112
17455 Registered Users

Generated in 0.075 seconds in which 0.027 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