|
|
|||||||
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? |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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! |
||||||||
|
|
|||||||
Nemas problemas :). Glad to help. Good luck, and don't ponder on questions to long, ppl are here to help |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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? |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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! |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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] |
||||||||
|
|
|||||||
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 |