Page 1 of 1 1
Topic Options
#57879 - 2001-08-02 06:43 PM Kixtart and group membership
Anonymous
Unregistered


Good day I am working on a script to map printers by group membership. The script runs great when using userid to check group membership. In windows 2000 you can assign computer accounts to groups does anyone know how to check is a computer account is a member of a group. I want to map printers by computer accounts being a member of a group.

The printer script I have my username groupmembership is below if anyone has any ideas that would be great

Steve


;--------------------------Heading--------------------------------------
;**
;** Script: Default Printer Mappin
;** Version: 1.0
;** Created: Wednesday -August 1, 2001
;**
;** Author: Steve Beaver
;** E-mail: steve.beaver@cibc.com
;**
;-----------------------------------------------------------------------
$printsrv="\\MTLFP1\"
$defprinter=""
if ingroup("APRN1") $defprinter=($printsrv+"PRN1") gosub "printcheck" endif
if ingroup("APRN2") $defprinter=($printsrv+"PRN2") gosub "printcheck" endif
if ingroup("APRN3") $defprinter=($printsrv+"PRN3") gosub "printcheck" endif
if ingroup("APRN4") $defprinter=($printsrv+"PRN4") gosub "printcheck" endif
if ingroup("APRN5") $defprinter=($printsrv+"PRN5") gosub "printcheck" endif
if ingroup("APRN6") $defprinter=($printsrv+"PRN6") gosub "printcheck" endif
if ingroup("APRN7") $defprinter=($printsrv+"PRN7") gosub "printcheck" endif
if ingroup("APRN8") $defprinter=($printsrv+"PRN8") gosub "printcheck" endif
if ingroup("APRN9") $defprinter=($printsrv+"PRN9") gosub "printcheck" endif
if ingroup("APRN10") $defprinter=($printsrv+"PRN10") gosub "printcheck" endif
if ingroup("APRN11") $defprinter=($printsrv+"PRN11") gosub "printcheck" endif
if ingroup("APRN12") $defprinter=($printsrv+"PRN12") gosub "printcheck" endif
if ingroup("APRN13") $defprinter=($printsrv+"PRN13") gosub "printcheck" endif
if ingroup("APRN14") $defprinter=($printsrv+"PRN14") gosub "printcheck" endif
if ingroup("APRN15") $defprinter=($printsrv+"PRN15") gosub "printcheck" endif
if ingroup("APRN16") $defprinter=($printsrv+"PRN16") gosub "printcheck" endif
if ingroup("APRN17") $defprinter=($printsrv+"PRN17") gosub "printcheck" endif
if ingroup("APRN18") $defprinter=($printsrv+"PRN18") gosub "printcheck" endif
if ingroup("APRN19") $defprinter=($printsrv+"PRN19") gosub "printcheck" endif

SELECT
CASE ingroup("PRN1") $defprinter=($printsrv+"PRN1")
CASE ingroup("PRN2") $defprinter=($printsrv+"PRN2")
CASE ingroup("PRN3") $defprinter=($printsrv+"PRN3")
CASE ingroup("PRN4") $defprinter=($printsrv+"PRN4")
CASE ingroup("PRN5") $defprinter=($printsrv+"PRN5")
CASE ingroup("PRN6") $defprinter=($printsrv+"PRN6")
CASE ingroup("PRN7") $defprinter=($printsrv+"PRN7")
CASE ingroup("PRN8") $defprinter=($printsrv+"PRN8")
CASE ingroup("PRN9") $defprinter=($printsrv+"PRN9")
CASE ingroup("PRN10") $defprinter=($printsrv+"PRN10")
CASE ingroup("PRN11") $defprinter=($printsrv+"PRN11")
CASE ingroup("PRN12") $defprinter=($printsrv+"PRN12")
CASE ingroup("PRN13") $defprinter=($printsrv+"PRN13")
CASE ingroup("PRN14") $defprinter=($printsrv+"PRN14")
CASE ingroup("PRN15") $defprinter=($printsrv+"PRN15")
CASE ingroup("PRN16") $defprinter=($printsrv+"PRN16")
CASE ingroup("PRN17") $defprinter=($printsrv+"PRN17")
CASE ingroup("PRN18") $defprinter=($printsrv+"PRN18")
CASE ingroup("PRN19") $defprinter=($printsrv+"PRN19")
ENDSELECT
if $defprinter<>""
$printerexists=0 $lptprinter=0 $index=0
rintloop
$printer=enumvalue("$HKCUSMWNTCV\PrinterPorts",$index)
$printerport=readvalue("$HKCUSMWNTCV\PrinterPorts","$printer")
if @error=0
if $printer=$defprinter $printerexists=1 endif
if instr("$printerport","LPT") $lptprinter=1 endif
$index=$index+1
goto printloop
endif
if $printerexists=0
$=addprinterconnection("$defprinter")
if $lptprinter=0
$=setdefaultprinter("$defprinter")
endif
endif
endif
exit
rintcheck
if $defprinter<>""
$printerexists=0 $lptprinter=0 $index=0
rintloop
$printer=enumvalue("$HKCUSMWNTCV\PrinterPorts",$index)
$printerport=readvalue("$HKCUSMWNTCV\PrinterPorts","$printer")
if @error=0
if $printer=$defprinter $printerexists=1 endif
if instr("$printerport","LPT") $lptprinter=1 endif
$index=$index+1
goto printloop
endif
if $printerexists=0
$=addprinterconnection("$defprinter")
if $lptprinter=0
$=setdefaultprinter("$defprinter")
endif
endif
endif
RETURN

Top
#57880 - 2001-08-03 04:20 PM Re: Kixtart and group membership
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Steve,

Rather than try to re-hash this out here. Please visit my response at - http://win-scripts.com

Thanks!

- Kent

[ 03 August 2001: Message edited by: kdyer ]

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#57881 - 2002-07-31 06:39 PM Re: Kixtart and group membership
JasLC Offline
Fresh Scripter

Registered: 2002-05-29
Posts: 39
Loc: Fort Worth
Kent, I cannot navigate to your link. Where can I find the answer to Steve's question? I am facing the same issue and would like a script to check group membership of the current computer through a login script to install printers.

Thanks! [Razz]
Jason

Top
#57882 - 2002-07-31 06:47 PM Re: Kixtart and group membership
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Kent has change his address. New URL http://kentldyer.com/
Other changes in all kind of URLs are possible. Some kixtart/scripting related URL are updated
in our "Links to Favorite Sites" page.
Also it is possible to look at the user profile, which contains mostly the actual one.
The most active members with direct profile links can be find on our page Statistics - BB Specials.
greetings.

[ 31 July 2002, 18:58: Message edited by: MCA ]
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#57883 - 2002-07-31 06:57 PM Re: Kixtart and group membership
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yeah, but actually his reply can't be found there.

just have to wait for kent's answer...
_________________________
!

download KiXnet

Top
#57884 - 2002-07-31 07:00 PM Re: Kixtart and group membership
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Indeed. Kent didn't migrate the forum to his site. Possible that he can find the specific
information back.
greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#57885 - 2002-07-31 08:25 PM Re: Kixtart and group membership
JasLC Offline
Fresh Scripter

Registered: 2002-05-29
Posts: 39
Loc: Fort Worth
I've got a VBscript that may perform this function, but I don't know how to rewrite it. What would the following look like in Kixtart?

code:
   
Set objWshNetwork = WScript.CreateObject("WScript.Network")
Set objWshShell = WScript.CreateObject("WScript.Shell")
set objADSysInfo = CreateObject("ADSystemInfo")
strComputerName = objWshNetwork.ComputerName
strComputerDN = objADSysInfo.computername

set objGroup = GetObject("LDAP://CN=GroupName,OU=GroupOU,DC=Domain,DC=com")

If objGroup.IsMember("LDAP://" & strComputerDN) Then
WshShell.run "rundll32 printui.dll,PrintUIEntry /ga /c \\" & strComputerName & " /n <\\printserver\sharedprintername>"
End If

Thanks!
Jason

Top
#57886 - 2002-07-31 08:56 PM Re: Kixtart and group membership
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
code:
$objWshNetwork=CreateObject("WScript.Network")
$objWshShell=CreateObject("WScript.Shell")
$objADSysInfo = CreateObject("ADSystemInfo")
$strComputerName = $objWshNetwork.ComputerName
$strComputerDN = $objADSysInfo.computername

$objGroup=GetObject("LDAP://CN=GroupName,OU=GroupOU,DC=Domain,DC=com")

If $objGroup.IsMember("LDAP://"+$strComputerDN)
run "rundll32 printui.dll,PrintUIEntry /ga /c \\$strComputerName"+" /n <\\printserver\sharedprintername>"
EndIf

something like that...

[ 31 July 2002, 21:18: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#57887 - 2002-07-31 09:00 PM Re: Kixtart and group membership
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
You forgot to change the &'s to +'s.
Top
#57888 - 2002-07-31 09:17 PM Re: Kixtart and group membership
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
fixed that one.
also took freedom to use kix's run.

{edit}
found also two errorlines.

didn't I say something like?
I think I have never used wshcode nor vbs...

[ 31 July 2002, 21:19: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#57889 - 2002-08-01 05:41 PM Re: Kixtart and group membership
JasLC Offline
Fresh Scripter

Registered: 2002-05-29
Posts: 39
Loc: Fort Worth
Code:

code:
$objWshNetwork=CreateObject("WScript.Network")
$objWshShell=CreateObject("WScript.Shell")
$objADSysInfo = CreateObject("ADSystemInfo")
$strComputerName = $objWshNetwork.ComputerName
$strComputerDN = $objADSysInfo.computername
$objGroup=GetObject("LDAP://CN=GroupName,OU=GroupOU,DC=Domain,DC=com")
If $objGroup.IsMember("LDAP://"+$strComputerDN)
run "rundll32 printui.dll,PrintUIEntry /ga /c \\$strComputerName"+" /n <\\printserver\sharedprintername>"
EndIf

The above line's functionality: "$objGroup=GetObject("LDAP://CN=GroupName,OU=GroupOU,DC=Domain,DC=com")" is incorrect.

Issue: I need code that will get ALL of the group memberships for the specific computer.

Functionality: The computer will boot up, authenticate to AD, read its appropriate Group Policy, run the login script, then the login script will check all of the groups it is a member of. Once it gets this group membership, then it will install specific printers based upon group membership, as shown in the above code.

Does anyone know how to do this???

MANY thanks!
Jason

Top
#57890 - 2002-08-01 06:17 PM Re: Kixtart and group membership
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Jason, that code won't do what you want. I can help, but need more specifics. Are you a NT only shop? What is your client environment like?
Top
#57891 - 2002-08-01 09:08 PM Re: Kixtart and group membership
JasLC Offline
Fresh Scripter

Registered: 2002-05-29
Posts: 39
Loc: Fort Worth
Chris,

I am only wanting to implement this for Windows 2000 clients.

-Jason

Top
#57892 - 2002-08-01 09:11 PM Re: Kixtart and group membership
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Jason,

Sorry I did not get back with you sooner on this.

The board had closed about 6 weeks ago (as I remember).. However, it does look like you have a solution in hand?

Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#57893 - 2002-08-02 03:22 PM Re: Kixtart and group membership
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Jason, if you're running this on Win2K clients whats wrong with using 'If Ingroup(x)' and 'Addprinterconnnection'?
Top
#57894 - 2002-08-02 03:46 PM Re: Kixtart and group membership
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Jason might not have realized that KiXtart needs only one line of code for tasks where Windows Scripting Host requires at least 10 lines and call to two different objects. [Big Grin]

So, yes, INGROUP and ADDPRINTERCONNECTION would be the commands of choice.

Jason, you might want to take a look at the KiXtart manual to see the commands Kixtart offers.
_________________________
There are two types of vessels, submarines and targets.

Top
#57895 - 2002-08-05 08:16 PM Re: Kixtart and group membership
JasLC Offline
Fresh Scripter

Registered: 2002-05-29
Posts: 39
Loc: Fort Worth
Chris and sealeopard...

to my knowledge, INGROUP does not recognize machine accounts within groups.

-Jason

Top
Page 1 of 1 1


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

Who's Online
1 registered (Allen) and 483 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.1 seconds in which 0.07 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