ekainyah
(Getting the hang of it)
2006-10-12 04:08 PM
IF INGROUP HELP

I am finding difficulties in getting this script to run successfuly. I want a different drive to be map for users depending on the group they belong to in the domain so i write this simple code but it does not work at all. Below is the script

IF INGROUP("ITDEPT")
USE T: "\\SERVER1\APPS"

ELSE

IF INGROUP("FINANCE")
USE P: "\\SERVER3\ACCOUNTS"

ELSE

IF INGROUP("SURPAC USERS")
USE G: "\\SERVER9\DATA"

ELSE ENDIF


BUT when a user in one of these groups logs on to the domain, he does not get the map drive. Hope somebody can really help me to sort this please


Regards
Edmund


Björn
(Korg Regular)
2006-10-12 04:29 PM
Re: IF INGROUP HELP

structure is IF something ELSE something else ENDIF
So you might wanna do:
Code:

IF INGROUP("ITDEPT")
USE T: "\\SERVER1\APPS"
ENDIF


IF INGROUP("FINANCE")
USE P: "\\SERVER3\ACCOUNTS"
ENDIF


IF INGROUP("SURPAC USERS")
USE G: "\\SERVER9\DATA"
ENDIF


If you wanna use ELSE, it should in this case be used something like this:
Code:


IF INGROUP("SURPAC USERS")
USE G: "\\SERVER9\DATA"
ELSE
USE G: "\\SOMEOTHERSERVER\DATA"
ENDIF


This makes it that if you're in the group SURPAC USERS, g: gets mapped to \\server9\data, and if you're not in the group, it mappes something else to G: in this example.


ekainyah
(Getting the hang of it)
2006-10-12 04:58 PM
Re: IF INGROUP HELP

i just try it again with what you written above but it still does not map the drive at all.

Björn
(Korg Regular)
2006-10-12 05:06 PM
Re: IF INGROUP HELP

Mkay.. First of, is the user in the group, etc etc?
second, try this:
Code:

IF INGROUP("ITDEPT")
'In group ITDEPT' ?
USE T: "\\SERVER1\APPS"
@ERROR ' - ERROR' @SERROR ' - SERROR' ?
ELSE
'NOT in group ITDEPT' ?
ENDIF


IF INGROUP("FINANCE")
'In group FINANCE' ?
USE P: "\\SERVER3\ACCOUNTS"
@ERROR ' - ERROR' @SERROR ' - SERROR' ?
ELSE
'NOT in group FINANCE' ?
ENDIF


IF INGROUP("SURPAC USERS")
'In group SURPAC USERS'
USE G: "\\SERVER9\DATA"
@ERROR ' - ERROR' @SERROR ' - SERROR' ?
ELSE
'NOT in group SURPAC USERS' ?
ENDIF


Second, is the drives already mapped?


Gargoyle
(MM club member)
2006-10-12 05:12 PM
Re: IF INGROUP HELP

If you need to do more than one comparison, Select - Case - EndSelect, is a much better way to do it.

Code:

Select
Case INGROUP("ITDEPT") = 1
USE T: "\\SERVER1\APPS"

Case INGROUP("FINANCE")= 1
USE P: "\\SERVER3\ACCOUNTS"

Case INGROUP("SURPAC USERS") = 1
USE G: "\\SERVER9\DATA"

EndSelect



You may want to also look at what the errors are thereby giving you an idea why they are not mapping

Code:

Case INGROUP("ITDEPT") = 1
? "InGroup error: "@error
USE T: "\\SERVER1\APPS"
? "Use Error: "@error



Björn
(Korg Regular)
2006-10-12 05:21 PM
Re: IF INGROUP HELP

Garg, what is a user is in two groups / all the groups ?
second, I prefer @SERROR - looking thro the error-codes isn't really my style ;P


Gargoyle
(MM club member)
2006-10-12 05:25 PM
Re: IF INGROUP HELP

Details, details, what do you want... And yes @Serror is a good way to go as well

ekainyah
(Getting the hang of it)
2006-10-12 05:32 PM
Re: IF INGROUP HELP

The drives are not already mapped and i just don't know what is happening here. I tried again with the above script and nothing happen. I am totally confused.

Björn
(Korg Regular)
2006-10-12 05:33 PM
Re: IF INGROUP HELP

then lets start with how you're calling the script ? both during logon and now.

ekainyah
(Getting the hang of it)
2006-10-12 05:43 PM
Re: IF INGROUP HELP

I will appreciate that very much b'cos when i tried using the kixtart last yr i had no succss in the normal inplementation so then i have to create a kix file like financ.kix and place this cmd kix32.exe finance.kix in each of the finance users profile under the user properties. That is really a tidious job to do so if i can get the normal way for kixtart to work, i will be very very grateful please.

Björn
(Korg Regular)
2006-10-12 05:52 PM
Re: IF INGROUP HELP

well, I would appreciate if you provided the info I asked for so we can help you

Ways to start and execute kixtart-scripts during logons can be found in the faq-section otherwise ( a bit too much to bluur out here..;) )


Gargoyle
(MM club member)
2006-10-12 05:53 PM
Re: IF INGROUP HELP

What type of domain are you implementing KiX in?
How are you calling your script now..?
When testing your script how are you calling it?


ekainyah
(Getting the hang of it)
2006-10-12 06:04 PM
Re: IF INGROUP HELP

ok, i am implementing kix on a windows 2003 server platform. The script is being run by placing this comand "kix32.exe surpac.kix" in the users properties profile. That is exactly what i am doing now. so please help me get off this tidious job.

Björn
(Korg Regular)
2006-10-12 06:08 PM
Re: IF INGROUP HELP

mkay, good start.
But, that's not the way to call it.
Check this out: How to run kixtart
In case the link is broken, the thread you're looking for is under FAQ-section, titled 'Use of %0\..\ to launch KiX '.
Basically, in the userprofile-tab, use logon.bat or something like that.
In your logon.bat (placed on the notlogon-share), you call the script.


Witto
(MM club member)
2006-10-12 07:05 PM
Re: IF INGROUP HELP

Quote:


The script is being run by placing this comand "kix32.exe surpac.kix" in the users properties profile.




I would think this is OK if you just have Windows NT (and higher) Workstations, no Win9x.
I think another approach is GPO.
Create GPO on OU with the users that need a certain script.
Go to User Configuration --> Windows Settings --> Scripts (Logon/Logoff) --> Logon
Ad a new script, the "script name" is wkix32.exe, the "script parameters" is your script file. Do not forget to copy the files in the policiy directory (You can open a browser clicking the "Show Files" button in the "Logon Properties" Window).


Björn
(Korg Regular)
2006-10-13 08:12 AM
Re: IF INGROUP HELP

Witto, you sure about that? I've personally never seen it working (using kix kixscript.kix from the users profile-tab) - will have to try tho.

ekainyah
(Getting the hang of it)
2006-10-13 09:31 AM
Re: IF INGROUP HELP

You see what i want to avoid is putting the command in users profile b'cos that is really tidious and if i can implement it with only script in the sysvol then that will be very easy.

Mart
(KiX Supporter)
2006-10-13 09:38 AM
Re: IF INGROUP HELP

You could make a master script that calls the other scripts based on the user, a group, a site or whatever you need. If you put the master script in the users profile then changes would only have to be made in on place being the master script when a script for a new department, a new site, etc... is added.

Björn
(Korg Regular)
2006-10-13 02:24 PM
Re: IF INGROUP HELP

I really belive you need to check out the FAQ-section on how to set it up.

ekainyah
(Getting the hang of it)
2006-10-13 03:27 PM
Re: IF INGROUP HELP

I am going through the FAQ-section to get the set up from stratch to see how it goes this time.

Björn
(Korg Regular)
2006-10-13 03:42 PM
Re: IF INGROUP HELP

Post if you need help / found the issue so the community can benefit from your findings

ekainyah
(Getting the hang of it)
2006-10-16 05:43 PM
Re: IF INGROUP HELP

I have done a lot but i'm getting very disappointed.This is what i did. i place the kix32.exe file, a logon.kix and a batch file logon.bat files all in the Sysvol folder in the WINDOWS\SYSVOL\sysvol\domain.com\scripts. Now in inside the logon.kix i have

IF Ingroup ("itdept")
use x: /DEL /PERSISTENT
use Y: /DEL /PERSISTENT
use x: "\\servername\surpacdata
use y: "\\servername\department
EndIf


Then within the batch file i have this:
kix32.exe logon.kix.

And in GPO under user configuration/windows settings/scripts/logon i have addeded the batch file logon.bat.

But still it does not work at all for me. Wondering what the hell is playing up with me. looks like this might not work for me.
any help


Mart
(KiX Supporter)
2006-10-16 05:48 PM
Re: IF INGROUP HELP

Small chance but what happens when you put the domain name in front of the group so you would get \\domain\group?

ekainyah
(Getting the hang of it)
2006-10-16 05:57 PM
Re: IF INGROUP HELP

I place the domain in as

IF Ingroup ("domain\itdept")
and still doen't work.


NTDOCAdministrator
(KiX Master)
2006-10-16 07:20 PM
Re: IF INGROUP HELP

Please try something like this for a test account.

Code:
If Not @LogonMode
Break On
Else
Break Off
EndIf
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')
$SO=SetOption('WrapAtEOL','On')
 
Dim $NoCache, $x
$NoCache = DelKey('HKCU\Software\KiXtart\TokenCache')
@KiX ?
If InGroup(@Domain+'\itdept')
'Found in ITDEPT Group' ?
Else
'Did not find in ITDEPT Group' ?
EndIf
 
'Press any key to continue...'
Get $x


 


Les
(KiX Master)
2006-10-16 08:01 PM
Re: IF INGROUP HELP

You are missing quotes.

Kdyer
(KiX Supporter)
2006-10-16 08:38 PM
Re: IF INGROUP HELP

Quote:


IF Ingroup ("itdept")
use x: /DEL /PERSISTENT
use Y: /DEL /PERSISTENT
use x: "\\servername\surpacdata
use y: "\\servername\department
EndIf

Then within the batch file i have this:
kix32.exe logon.kix.

And in GPO under user configuration/windows settings/scripts/logon i have addeded the batch file logon.bat.

But still it does not work at all for me. Wondering what the hell is playing up with me. looks like this might not work for me.
any help




Further to what Les was saying about your missing quotes:
Code:

IF Ingroup ("itdept")
use x: /DEL /PERSISTENT
use Y: /DEL /PERSISTENT
use x: "\\servername\surpacdata"
use y: "\\servername\department"
EndIf



HTH,

Kent


ekainyah
(Getting the hang of it)
2006-10-17 10:25 AM
Re: IF INGROUP HELP

sorry on the actuall scripts i have both quotes on which didn't work.

NTDOC,
i tried with your codes which i was expecting to see either 'Found in ITDEPT Group' or not but i don't c anything at all. i am wondering what i might be doing wrong or what is preventing the script to run.


NTDOCAdministrator
(KiX Master)
2006-10-17 10:34 AM
Re: IF INGROUP HELP

Hi Edmund,

Well how are you calling the script?

What Server Domain model? Active Directory or NT4?

Are you sure that all your servers have replication working correctly?

Are you running any Windows 9x clients?
If only NT/2000/XP clients then you don't need a batch file to call KIX32 and your script.


ekainyah
(Getting the hang of it)
2006-10-17 11:37 AM
Re: IF INGROUP HELP

NTDOC,
I AM RUNING 2003 SERVER DOMAIN WITH ACTIVE DIRECTORY AND HAVE REPLICATION WORKING FINE B'COS MY DFS HAS BEING AND STILL DOING FINE AS WELL AS DC REPLICATIONS.ALL CLIENTS ARE XP WITH LESS THAN 10 RUNNING 2000.
THIS IS HOW I CALL THE SCRIPT:

i place the kix32.exe file, a logon.kix and a batch file logon.bat files all in the Sysvol folder in the WINDOWS\SYSVOL\sysvol\domain.com\scripts. Now in inside the logon.kix i have

IF Ingroup ("itdept")
use x: /DEL /PERSISTENT
use Y: /DEL /PERSISTENT
use x: "\\servername\surpacdata
use y: "\\servername\department
EndIf


Then within the batch file i have this:
kix32.exe logon.kix.

And in GPO under user configuration/windows settings/scripts/logon i have addeded the batch file logon.bat.

I DON'T KNOW WHAT IS HAPPENING TO THIS.


ekainyah
(Getting the hang of it)
2006-10-17 11:44 AM
Re: IF INGROUP HELP

SORRY I HAVE THE QUOTES ON LIKE THIS:
use x: "\\servername\surpacdata"
use y: "\\servername\department"


Björn
(Korg Regular)
2006-10-17 01:25 PM
Re: IF INGROUP HELP

In the GPO, under scripts you've got your kix-executable and your kix-scriptfile, in the user logon-scripts, you can then set kixexecutable.exe scriptfile.kix . afterwards this is set and replicated out, restart your machine you're testing it on.

First off - make sure like you've done eariler (I think) that your script acctually works. copy it down to a workstation, with a user that's in one or some / all of the groups, run it and verify it. does it work there? Then it should work in your gpo. Mind tho that setting up via a GPO is a bit tricky - using the old way mentioned before -> in each users profile, set the logon.bat and in the netlogon-share place the files (logon.bat, kix-executable and script-file/files).

If you are still go on via a GPO - verify that it acctually gets to the machine and user (gpresult on the machine with the user / wmi-query from the ad-mmc).
Another easy way is to log each logon - make the script write to a file or why not the log. eitherway can be good to use during test-phase.


ekainyah
(Getting the hang of it)
2006-10-17 04:19 PM
Re: IF INGROUP HELP

Bjorn i am a little bit confuse with what you are saying.
what you saying is to place both kix32.exe and the kix files under
user configuration/windows settings/scripts/logon?


ekainyah
(Getting the hang of it)
2006-10-17 04:40 PM
Re: IF INGROUP HELP

when i run this script in command prompt on the test computer
c:\kix>kix32 logon.kix /d
it runs ok without any error messenge but it does not map the drive

and the content of the logon.kix is
IF INGROUP("ITDEPT")
USE X: /DEL /PERSISTENT
USE Y: /DEL /PERSISTENT
USE X: "\\SERVER\SURPAC"
USE Y: "\\SERVER\DEPARTMENT"
ENDIF


ekainyah
(Getting the hang of it)
2006-10-17 04:49 PM
Re: IF INGROUP HELP

Now when i try the script below that NTDOC has to me to test, it is able to detect when a user is in the itdept group or not so it means is on the test computer but why it not working for the map drive and on the domain is what is killing me.


If Not @LogonMode
Break On
Else
Break Off
EndIf
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')
$SO=SetOption('WrapAtEOL','On')

Dim $NoCache, $x
$NoCache = DelKey('HKCU\Software\KiXtart\TokenCache')
@KiX ?
If InGroup(@Domain+'\itdept')
'Found in ITDEPT Group' ?
Else
'Did not find in ITDEPT Group' ?
EndIf

'Press any key to continue...'
Get $x


NTDOCAdministrator
(KiX Master)
2006-10-17 09:04 PM
Re: IF INGROUP HELP

Well for now take an account and set it up in Active Directory Users and Computers

Then modify the logon to be something like this. Using either KIX32.EXE or WKIX32.EXE and the name of your Script file.

Since you're using only 2000/XP workstations then you don't need to use a batch file.




Make sure the logon has the script information that I gave you.

You should see it on screen and have to press a key to continue.

Then once that is working you can look at modifying the script to actually do the drive mappings.


ekainyah
(Getting the hang of it)
2006-10-18 12:58 PM
Re: IF INGROUP HELP

NTDOC,
NOW I AM ALMOST THERE. IT WORKS ON A LOCAL TEST COMPUTER ALRIGHT AND I ALSO WORKS WHEN I PLACE KIX32.EXE MAP.KIX IN A TEST USER PROFILE AS YOU INDICTED ABOVE. NOW I AM LEFT WITH HOW TO GET BATCH FILE TO WORK. I HAVE CREATED A BATCH FILE NETMAP.BAT AND PLACE THIS COMMAND "KIX32.EXE MAP.KIX" IN IT AND PLACE IT UNDER GROUP POLICY "UESR CONFIGURATION/WINDOWS SETTINGS/SCRIPTS/LOGON.

THE REASON WHY I NEED THIS BATCH TO RUN IS THAT WE HAVE A LOT OF USERS IN OURS DOMAIN SO TO PUT THE "KIX32.EXE MAP.KIX" IN EVERY USER'S PROFILE IS ACTUALLY A BIG WORK FOR ME.I ACUTALLY HAVE A BATCH FILE IN THE LOGON WHICH WORKS ALRIGHT SO JUST WONDERING WHY THIS IS NOT.

EDMUND


Björn
(Korg Regular)
2006-10-18 03:54 PM
Re: IF INGROUP HELP

My bad ekainyah. Didn't know that you could do like doc just posted, and you said you've done previously. And to answer your question, yes I belive that was what I meant. but, perhaps you should build your scripts a bit different so you can place 'kix32.exe kixfile.kix' there. then make the script decide and run the rest.

ekainyah
(Getting the hang of it)
2006-10-18 06:47 PM
Re: IF INGROUP HELP

OK BJORN. NOW I WANT TO BE ABLE TO USE THE BATCH FILE TO GET THIS WHOLE THING TO RUN.

Les
(KiX Master)
2006-10-18 06:50 PM
Re: IF INGROUP HELP

Please stop shouting in uppercase.

Benny69
(MM club member)
2006-10-18 07:19 PM
Re: IF INGROUP HELP

hehee, Les made a funny!

NTDOCAdministrator
(KiX Master)
2006-10-18 07:30 PM
Re: IF INGROUP HELP

Hi ekainyah,

I'd love to help but to be honest I've never setup accounts to run in that manner.

Les may have or at least may know all the correct information as I'm not sure he does logon scripts himself but he is quite knowledgeable about it overall.

I can provide you with a script though that will go through all your accounts and add the logon information automatically if you like.


Les
(KiX Master)
2006-10-18 07:43 PM
Re: IF INGROUP HELP

Quote:

hehee, Les made a funny!



No, I did not. I am serious. SHOUTING is RUDE!


ekainyah
(Getting the hang of it)
2006-10-19 06:47 PM
Re: IF INGROUP HELP

ok

ekainyah
(Getting the hang of it)
2006-10-19 07:22 PM
Re: IF INGROUP HELP

NTDOC i will be very grateful if you can give that to me. once it will automatically add the script to the user profile i will be fine with that.

NTDOCAdministrator
(KiX Master)
2006-10-19 08:38 PM
Re: IF INGROUP HELP

Well Les actually provides code for that here on the last post but the rest of the thread may be a good read for you as well.

Newbie Question (Write AD Object)
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB13&Number=156871