#206749 - 2013-02-22 12:39 PM
INGROUP - Win7 - W2k8 Domain [solved]
|
badmin
Fresh Scripter
Registered: 2008-04-16
Posts: 7
|
Hi there, I've seen some threads about INGROUP not working but all relay to W2k Domains. I have a pretty new 2k8 R2 Domain with Windows 7 clients (SP1 installed) When I started I remember that it worked well. There's a small function "Mapdrives()":USE H: /DELETE /Persistent
USE G: /DELETE /Persistent
USE I: /DELETE /Persistent
USE J: /DELETE /Persistent
Use H: "\\srv01\User Homes\%username%" /PERSISTENT
Use I: "\\srv01\share2" /PERSISTENT
Use J: "\\srv01\share3" /PERSISTENT
IF INGROUP("Geschäftsführung")
Use G: "\\srv01\Geschäftsführung" /PERSISTENT
ENDIF Now I added a function called "Mapprinters()":
Function MapPrinter()
Shell "\\srv01\NETLOGON\con2prt.exe /f"
$ = AddPrinterConnection("\\srv01\PRT01 SHARP MX-2300N PCL6")
$ = AddPrinterConnection("\\srv01\PRT02 HP LaserJet P3015")
Select
Case InGroup ("prt01")
$ = SetDefaultPrinter("\\srv01\PRT01 SHARP MX-2300N PCL6")
Case InGroup ("prt02")
$ = SetDefaultPrinter("\\srv01\PRT02 HP LaserJet P3015")
Case 1 ;default - wenn keine andere option zutrifft
$ = SetDefaultPrinter("\\srv01\PRT01 SHARP MX-2300N PCL6")
EndSelect
EndFunction When the user logs on, all printers are connected but prt01 remains as standard even when the user is member of group prt02
The script is called via kix.bat in Sysvol: %LOGONSERVER%\NETLOGON\kix32.exe /f -i %LOGONSERVER%\NETLOGON\drives_printers.kix
There are no entries in the eventlog of the client. Do you have any ideas?
Thanks, Harry
Edited by badmin (2013-02-25 12:00 PM) Edit Reason: marked as solved
|
|
Top
|
|
|
|
#206750 - 2013-02-22 12:55 PM
Re: INGROUP - Win7 - W2k8 Domain
[Re: badmin]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
|
Harry,
Welcome to KORG. When posting your code, put "code tags" around it to preserve the formatting. Edit your original post to see how it's done.
Most likely, the user is a member of PRT01 group. In a Case statement, the first condition to satisfy the test will be performed. If users are potentially members of multiple groups, you will need to define a priority scheme of some kind, save the printers (possibly in an array) and then set the default based on the highest priority.
Our login script handles this through different mechanisms, such as - a table of per-user or per-computer DefaultPrinter settings - a local DEFAULTPRINTER environment variable, again by user or machine - PRIORITY values in the resource table - SetDefault parameter for each resource
While processing, a "DefaultEligible" flag is set, and then logic is applied to find the best selection for the default printer based on all printers that have the DefaultEligible flag set.
You can review the user guide for the script on our web site (see my sig) to get some ideas for your script, or download our script to try. It's free to use in environments with 4 or fewer domain controllers.
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#206754 - 2013-02-22 02:57 PM
Re: INGROUP - Win7 - W2k8 Domain
[Re: Glenn Barnas]
|
badmin
Fresh Scripter
Registered: 2008-04-16
Posts: 7
|
Harry,
Welcome to KORG. When posting your code, put "code tags" around it to preserve the formatting. Edit your original post to see how it's done.
Most likely, the user is a member of PRT01 group. In a Case statement, the first condition to satisfy the test will be performed. If users are potentially members of multiple groups, you will need to define a priority scheme of some kind, save the printers (possibly in an array) and then set the default based on the highest priority.
Our login script handles this through different mechanisms, such as - a table of per-user or per-computer DefaultPrinter settings - a local DEFAULTPRINTER environment variable, again by user or machine - PRIORITY values in the resource table - SetDefault parameter for each resource
While processing, a "DefaultEligible" flag is set, and then logic is applied to find the best selection for the default printer based on all printers that have the DefaultEligible flag set.
You can review the user guide for the script on our web site (see my sig) to get some ideas for your script, or download our script to try. It's free to use in environments with 4 or fewer domain controllers.
Glenn
Hi Glenn,
thanks for you fast answer and sorry for the quotes. I'll do better next time. 
Your example of multiple groups is right, but we only use it in a very simple way. Users tell us which printer they'd like to have as default and I put/move their account in the according group.
Using your or my way - the ingroup command is the same and it doesn't work. I only find postings according to Windows 2k Domains.
Thanks again for the info on my %shell% command. I'll change that soon 
Harry
|
|
Top
|
|
|
|
#206757 - 2013-02-22 04:37 PM
Re: INGROUP - Win7 - W2k8 Domain
[Re: badmin]
|
ShaneEP
MM club member
   
Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
|
Perhaps none of the groups are being detected, and it's simply setting the default according to the Case 1 which also happens to be the same as PRT01. I would recommend changing the Case 1 line to the other printer just as a test to see if you get different results.
Case 1 ;default - wenn keine andere option zutrifft
$ = SetDefaultPrinter("\\srv01\PRT02 HP LaserJet P3015")
|
|
Top
|
|
|
|
#206764 - 2013-02-23 10:46 AM
Re: INGROUP - Win7 - W2k8 Domain
[Re: Lonkero]
|
badmin
Fresh Scripter
Registered: 2008-04-16
Posts: 7
|
Ok, changing the default to another than the first connected sounds like a good debugging idea. How can I add general debugging to the script?
I'm using /f already.
|
|
Top
|
|
|
|
#206765 - 2013-02-23 10:47 AM
Re: INGROUP - Win7 - W2k8 Domain
[Re: badmin]
|
badmin
Fresh Scripter
Registered: 2008-04-16
Posts: 7
|
Oh I forgot to mention that my DC's are 2012 machines. Maybe there's an issue with that?
|
|
Top
|
|
|
|
#206790 - 2013-02-25 11:21 AM
Re: INGROUP - Win7 - W2k8 Domain
[Re: Glenn Barnas]
|
badmin
Fresh Scripter
Registered: 2008-04-16
Posts: 7
|
Today I started with "messagebox-debugging"  Put a messagebox to the ingroup selection and see if it pops up.
-> Ingroup works fine! there's a problem with
$ = SetDefaultPrinter("\\servername\XGMS-MUC1-PRT05 HP LaserJet P3011P3015 PCL6")
Edited by badmin (2013-02-25 11:21 AM)
|
|
Top
|
|
|
|
#206791 - 2013-02-25 11:58 AM
Re: INGROUP - Win7 - W2k8 Domain
[Re: badmin]
|
badmin
Fresh Scripter
Registered: 2008-04-16
Posts: 7
|
Ok, think it's done. There's a litte "/" that makes the difference between the "share-name" and the "printername" SetDefaultPrinter uses the printername, addprinterconnection uses the share-name
|
|
Top
|
|
|
|
#206794 - 2013-02-25 02:27 PM
Re: INGROUP - Win7 - W2k8 Domain
[Re: Mart]
|
badmin
Fresh Scripter
Registered: 2008-04-16
Posts: 7
|
Ok, think it's done. There's a litte "/" that makes the difference between the "share-name" and the "printername" SetDefaultPrinter uses the printername, addprinterconnection uses the share-name And that is exactly why having both of them set to the same value is best practice in my opinion
Absolutely! I didn't want them to be different! That's why it took me so long to figure it out
Edited by badmin (2013-02-25 02:28 PM)
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1172 anonymous users online.
|
|
|