Page 1 of 3 123>
Topic Options
#105682 - 2003-10-10 12:19 AM Primary computer group membership
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Is there a Function or way to test for the primary computer group membership along the lines of @primarygroup or ComputerInGroup.udf?

Currently @primarygroup returns primary user group membership, ComputerInGroup returns all computer groups.

I would like to set the default printer based on computer group membership.

Thanks.

Top
#105683 - 2003-10-10 12:28 AM Re: Primary computer group membership
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
I'm not 100% sure what you are asking for...But this would add printers depending upon primary group. You dont have to check membership...The user will always be a member of their returned primarygroup. You just need to change the groups and the printer shares. If there are more than a few...Then perhaps a Select statement would work better.

code:
 
If @PrimaryGroup = "OfficeGroup"
AddPrinterConnection ("\\PrintServer\OfficePrinter")
Endif
If @PrimaryGroup = "PlantGroup"
AddPrinterConnection ("\\PrintServer\PlantPrinter")
Endif



[ 10. October 2003, 00:29: Message edited by: CitrixMan ]

Top
#105684 - 2003-10-10 12:32 AM Re: Primary computer group membership
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
did I read right...
you are searching for computerprimarygroup() thingie?
_________________________
!

download KiXnet

Top
#105685 - 2003-10-10 12:35 AM Re: Primary computer group membership
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
ahhh I see now...Computers primary group. I thought it seemed a little too simple.
Top
#105686 - 2003-10-10 12:37 AM Re: Primary computer group membership
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
A Computer Primary Group, this is a new one on me, where would you set this in AD???
Top
#105687 - 2003-10-10 01:02 AM Re: Primary computer group membership
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
haven't heard either, but don't have AD running either.

I see making printermapping groups for the computers as the easiest option.
_________________________
!

download KiXnet

Top
#105688 - 2003-10-10 01:08 AM Re: Primary computer group membership
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
quote:
primaryGroupID
The primaryGroupID property is a single-valued property containing the relative identifier (RID) for the primary group of the user. By default, this is the RID for the Domain Users group. This property is not used in the context of the Active Directory.

You can create a set of groups that represent the default printers. Then you can just add logic to check for members in a "defaultPrinter" group. If so, then call the SetDefaultPrinterfunction for the printer name.

You can include the printer name i either in the name of the group or in the description field of the group.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#105689 - 2003-10-10 01:13 AM Re: Primary computer group membership
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You would have to test this but you may be able to use the WinNT:// provider to set the PrimaryGroupID on the computer account and then check it the same way.

code:
$CompAcct = GetObject("WinNT://DomainName/CompName1$$,user")
$PrimaryGrpID = $compAcct.Get("PrimaryGroupID")



[ 10. October 2003, 01:13: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#105690 - 2003-10-10 03:46 AM Re: Primary computer group membership
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Thanks everyone.

To let you know what I'm up to, check this thread:
http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=007920

In AD, you can right click on the computer and set the primary group in the same manner that you can set a users default group.

I have seen others ask for this feature, and will find the thread and post here. I did not see a solution posted.

Top
#105691 - 2003-10-10 03:57 AM Re: Primary computer group membership
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
What solution? I just showed you how to retrieve the primarygroupID. Use the put method to set it.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#105692 - 2003-10-10 04:15 AM Re: Primary computer group membership
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Oops, sorry, Howard. I overlooked your post. I will try this tomorrow at work (12 hours from now).

Your help is appreciated.

[Embarrassed]

Terri

Top
#105693 - 2003-10-10 04:51 AM Re: Primary computer group membership
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Howard-

I couldn't wait 12 hours. Had to VPN work and try. I can't get it to work. I am using the following code to get the group membership of the computers and install the printers. Where I am having a problems is in reading the Primary group membership of the computer to use to set the default printer.

Your code is doing the same thing as the code I am using, please correct me if I am wrong. There could be something else going on.

code:
$WS = GetObject("WinNT://" + @domain + "/" + @wksta + "$$")
if @error
? @serror
else
for each $grp In $WS.Groups
$GrpName = $grp.Name
if left($GrpName,8) = "Printer_"
$printer = substr($GrpName,9)
$printer = join(split($printer,"_"),"\")

if not PriMapState("\\" + $printer)
? "Status - Printer not connected "+$printer
$S=AddPrinterConnection("\\" + $printer)
; $Returncode=AddPrinterConnection("\\" + $printer)
? "Status - Printer added "+$printer
? @serror
?
endif
endif
next


Top
#105694 - 2003-10-10 05:01 AM Re: Primary computer group membership
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
What is failing? You do not give any info or error messages. I do not see anywhere that you get the "primaryGroupID".
code:
break ON

$WS = GetObject("WinNT://" + @domain + "/" + @wksta + "$$,user")
if @error
? @serror
else
for each $grp In $WS.Groups
$GrpName = $grp.Name
if left($GrpName,8) = "Printer_"
$printer = substr($GrpName,9)
$printer = join(split($printer,"_"),"\")

if not PriMapState("\\" + $printer)
? "Status - Printer not connected "+$printer
$S=AddPrinterConnection("\\" + $printer)
; $Returncode=AddPrinterConnection("\\" + $printer)
? "Status - Printer added "+$printer
? @serror
?
endif
endif
next
$PrimaryGrpID = $WS.Get("PrimaryGroupID")
? "@error @serror"
? $PrimaryGrpID
endif



[ 10. October 2003, 05:04: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#105695 - 2003-10-10 05:15 AM Re: Primary computer group membership
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Thanks, Howard.

Here is what I was testing, I was just posting my code as I thought your code to get primary was only going to get all groups. Mine didn't work, so I omitted. Not too wise, as you had nothing to review.

The modified code you posted is different, I'll work on that and let you know outcome.

code:
call @ScriptDir+'\PriMapState.udf'

;********** Prevent script from running on a server or Win95*********
if @userid = administrator
call @Scriptdir+'\osid.udf'
$os=osid()
if $os[1]='Win95' or $os[2]<>'Workstation'
exit 0
endif
endif

;********** Beginning of printer mapping *********

$WS = GetObject("WinNT://" + @domain + "/" + @wksta + "$$")
if @error
? @serror
else
for each $grp In $WS.Groups
$GrpName = $grp.Name
if left($GrpName,8) = "Printer_"
$printer = substr($GrpName,9)
$printer = join(split($printer,"_"),"\")

if not PriMapState("\\" + $printer)
? "Status - Printer not connected "+$printer
$S=AddPrinterConnection("\\" + $printer)
; $Returncode=AddPrinterConnection("\\" + $printer)
? "Status - Printer added "+$printer
? @serror
?
endif
endif
next

;set default printer

; $CompAcct = GetObject("WinNT://DomainName/CompName1$$,user")
$CompAcct = GetObject("WinNT://" + @domain + "/" + @wksta + "$$")

if @error
? @serror
else
$PrimaryGrpID = $compAcct.Get("PrimaryGroupID")
if left($PrimaryGrpID,8) = "Printer_"
$defprinter = substr($PrimaryGrpID,9)
$defprinter = join(split($printer,"_"),"\")
if PriMapState("\\" + $defprinter)
$S=SetDefaultPrinter ("\\" + $defprinter)
? "Status - Default Printer set"
? @serror
endif
endif
endif
endif



[ 11. October 2003, 01:42: Message edited by: tjcarst ]

Top
#105696 - 2003-10-10 05:23 AM Re: Primary computer group membership
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You will need to read up on exactly what the PrimaryGroupID is.

http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=006263

code:
$WS = GetObject("WinNT://" + @domain + "/" + @wksta + "$$, user")
if @error
? @serror
else
for each $grp In $WS.Groups
$GrpName = $grp.Name
if left($GrpName,8) = "Printer_"
$printer = substr($GrpName,9)
$printer = join(split($printer,"_"),"\")

if not PriMapState("\\" + $printer)
? "Status - Printer not connected "+$printer
$S=AddPrinterConnection("\\" + $printer)
; $Returncode=AddPrinterConnection("\\" + $printer)
? "Status - Printer added "+$printer
? @serror
?
endif
endif
next

;set default printer

$PrimaryGrpID = $WS.Get("PrimaryGroupID")
;This returns the RID (Relative Identifier) of the Group.
;This is NOT a group name
;You need code here to convert the RID to the group name
endif

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#105697 - 2003-10-10 05:33 AM Re: Primary computer group membership
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Using the following script, this is the screen output from the default printer:

-----------------------------------------
Status - Printer not connected MRH-01\Q-MIS1
Status - Printer added MRH-01\Q-MIS1
The operation completed successfully.

Status - Printer not connected MRH-01\Q-MIS2
Status - Printer added MRH-01\Q-MIS2
The operation completed successfully.

Status - Printer not connected MRH-01\Q-MIS2-COLOR
Status - Printer added MRH-01\Q-MIS2-COLOR
The operation completed successfully.

0 The operation completed successfully.
7278
-----------------------------------------

My pc is a member of three groups and the printers are added if not present, not added if present.

The wrong printer is default, it is not the
primary group.

code:
call @ScriptDir+'\PriMapState.udf'

;********** Prevent script from running on a server or Win95*********
if @userid = administrator
call @Scriptdir+'\osid.udf'
$os=osid()
if $os[1]='Win95' or $os[2]<>'Workstation'
exit 0
endif
endif

;********** Beginning of printer mapping *********

$WS = GetObject("WinNT://" + @domain + "/" + @wksta + "$$")
if @error
? @serror
else
for each $grp In $WS.Groups
$GrpName = $grp.Name

if left($GrpName,8) = "Printer_"
$printer = substr($GrpName,9)
$printer = join(split($printer,"_"),"\")

if not PriMapState("\\" + $printer)
? "Status - Printer not connected "+$printer
$S=AddPrinterConnection("\\" + $printer)
? "Status - Printer added "+$printer
? @serror
?
endif

endif

next

;set default printer

$PrimaryGrpID = $WS.Get("PrimaryGroupID")
? "@error @serror"
? $PrimaryGrpID
if left($PrimaryGrpID,8) = "Printer_"
$defprinter = substr($PrimaryGrpID,9)
$defprinter = join(split($defprinter,"_"),"\")
if PriMapState("\\" + $defprinter)
$S=SetDefaultPrinter ("\\" + $defprinter)
? "Status - Default Printer set"
? @serror
endif
endif
endif



[ 10. October 2003, 05:38: Message edited by: tjcarst ]

Top
#105698 - 2003-10-10 05:37 AM Re: Primary computer group membership
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
as I read your output, it seems to never even executed the default printer piece of the script.
thus the default printer will be automatically set to first printer available by windows.
_________________________
!

download KiXnet

Top
#105699 - 2003-10-10 05:39 AM Re: Primary computer group membership
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Please see my previous post and read the link provided. There is some code buried in it that may help you.

7278 is the RID of the group. You need to use this to get the name of the group.

[ 10. October 2003, 05:39: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#105700 - 2003-10-10 05:46 AM Re: Primary computer group membership
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Yes. The output indicates that the result of the PrimaryGroup is 7278 and not Printer_MRH-01_Q-MIS2 as it should be. At least that is what I am using for setdefaultprinter in my instance.

How is the primary group returned numerically instead of by name? Maybe this is where the problem lies. My script only sets default printer if the groupnames starts with Printer_ and then uses the remainder of group name to determine printer name.

Terri

Top
#105701 - 2003-10-10 05:49 AM Re: Primary computer group membership
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
That is the issue.

Please READ the link (in a previous post) as this entire topic is discussed in detail. You need to learn about RIDs and SIDs when you start using items like PrimaryGroupID.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
Page 1 of 3 123>


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 918 anonymous users online.
Newest Members
rrosell, PatrickPinto, Raoul, Timothy, Jojo67
17877 Registered Users

Generated in 1.035 seconds in which 1.003 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org