Page 1 of 2 12>
Topic Options
#46934 - 2003-10-17 08:05 PM Enumerating Computer Account Group Membership
Mike Pratt Offline
Fresh Scripter

Registered: 2003-10-17
Posts: 18
Loc: Maine
I am trying to script network printer installation based upon the physical location a user logs on from...currently I am using DHCP reservations and scripting according to IP address and what group the user account is part of. What I'm trying to accomplish through KIX is to group my computer accounts and script the network printer according to what group the comptuer account is in.

Here's a snapshot of my KIX:

if INSTR("$groups","Nurses;") AND INSTR("$ipadd","10.1.1.201") OR INSTR("$ipadd","10.1.1.202") OR INSTR("$ipadd","10.1.1.203")
if ADDPRINTERCONNECTION ($pod1ptr) = 0 ? "Added printer connection...." endif
endif

Is it possible to script on computer account group membership?

Thanks!
Mike

Top
#46935 - 2003-10-17 08:29 PM Re: Enumerating Computer Account Group Membership
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Yes. See ComputerInGroup.udf http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000457

See also the last post in this thread for printers added based upon group membership http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=007920.

I have this working based upon variables because I have so many printers. It would be easier to do if you had fewer printers and could use ComputerInGroup.udf. Let me know if you want any more info on this, I am a beginner, so the experts here are a better source of help than me. I tend to need everything spelled out for me.

I also have one that works based upon a printsetup.ini file. All of my scripts have been obtained by code that exists here and tweaking done with the help of other here.

[ 17. October 2003, 20:35: Message edited by: tjcarst ]

Top
#46936 - 2003-10-17 08:40 PM Re: Enumerating Computer Account Group Membership
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Untested, but try this:

code:
call @scriptdir+'\computeringroup.udf'

if ComputerInGroup('nurses')=1 AND INSTR("$ipadd","10.1.1.201") OR INSTR("$ipadd","10.1.1.202") OR INSTR("$ipadd","10.1.1.203")

if ADDPRINTERCONNECTION ($pod1ptr) = 0 ? "Added printer connection...." endif

endif

tjcarst

Top
#46937 - 2003-10-17 08:44 PM Re: Enumerating Computer Account Group Membership
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
See also TCP/IP Primer, Part I - IP Addresses .
_________________________
There are two types of vessels, submarines and targets.

Top
#46938 - 2003-10-17 08:52 PM Re: Enumerating Computer Account Group Membership
Mike Pratt Offline
Fresh Scripter

Registered: 2003-10-17
Posts: 18
Loc: Maine
Awesome! Thanks guys, I'll give that a try and I'll post results...
Top
#46939 - 2003-10-20 06:38 PM Re: Enumerating Computer Account Group Membership
Mike Pratt Offline
Fresh Scripter

Registered: 2003-10-17
Posts: 18
Loc: Maine
Hi guys,

I am just getting back to testing this and I think I need a hand with the syntax...I'm a newbie to KIX...

I've tried putting the UDF in a seperate file and also incorporating it in the KIX script - I haven't had luck with either. I would prefer to have it in a seperate *.udf file...

1. So if I had this code in computeringroup.udf:

Function ComputerInGroup($group,optional $Domain)
Dim $oGrp
if not $domain $domain=@domain endif
$oGrp = GetObject("WinNT://" + $domain + "/" + $group + ",group" )
if @error exit 1 endif

if $oGrp.IsMember("WinNT://" + $domain + "/" + @wksta + "$$" )
$ComputerInGroup=1
else
$ComputerInGroup=0
endif
endfunction

2. I called upon the .udf with this code in my KIX script:

call @scriptdir+'\computeringroup.udf'

if ComputerInGroup("$groups","Bruns Pod 1;") AND INSTR("$ipadd","10.1.1.")
if ADDPRINTERCONNECTION ($ptrpod1) = 0 ? "Added printer connection...." endif
endif

3. I have put the computer account in the group called "Bruns Pod 1".

I know I'm missing syntax...could you help me out?

Thanks a million!
Mike

Top
#46940 - 2003-10-20 06:42 PM Re: Enumerating Computer Account Group Membership
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
See the FAQ Forum under How to use UDFs and TCP/IP Primer, Part I - IP Addresses .

You should also check the ComputerInGroup() UDF header for correct syntax as I'm pretty sure yoru syntax is incorrect.

Also, please don't use vars inside strings.
_________________________
There are two types of vessels, submarines and targets.

Top
#46941 - 2003-10-21 08:44 PM Re: Enumerating Computer Account Group Membership
Mike Pratt Offline
Fresh Scripter

Registered: 2003-10-17
Posts: 18
Loc: Maine
I still haven't gotten this to work...I copied the syntax for the computeringroup.udf from here:

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

I have 4 printers in 4 different locations that I want to map, so it's not really that complex...I basically have 4 pods, and depending on what pod users logon to I want them to receive that pod's printer...I must be close, but I'm getting tripped up on the syntax...

I have the computeringroup.udf in my netlogon directory, but I'm not sure what to have in my main kix script for syntax...any help would be appreciated!

Thanks,
Mike

Top
#46942 - 2003-10-21 09:28 PM Re: Enumerating Computer Account Group Membership
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Don't modify the ComputerInGroup.udf

Since you only have 4 printers, it would be easiest to write the code for each printer. You may want to check to see if it is already mapped using PriMapState.udf and set it to default using SetDefaultPrinter.

I know there is a way to use an array so you don't have to create the script for each printer, but will have to research this, as I, too am a new Kixtart user.

Change your script to this:
code:
$prtpod1="\\server\share1"
$prtpod2="\\server\share2"
$prtpod3="\\server\share3"
$prtpod4="\\server\share4"

call @scriptdir+'\computeringroup.udf'

if ComputerInGroup('Bruns Pod')=1 AND INSTR("$ipadd","10.1.1.")
if not PriMapState($prtpod1)
? "Status " $prtpod1 " not connected"
? @serror
$nul=AddPrinterConnection(\\server\$prtpod1)
? "Status - Added printer connection "$prtpod1
? @serror
$nul=SetDefaultPrinter($prtpod1)
? "Status - Default printer set "$prtpod1
endif
endif

Edited to include proper syntax. Thanks Howard, missed that. [Embarrassed]

tjcarst

[ 21. October 2003, 21:44: Message edited by: tjcarst ]

Top
#46943 - 2003-10-21 09:38 PM Re: Enumerating Computer Account Group Membership
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Read the TCP/IP Primer as the way you compare the IP Address will not work! UDFs are the way to go for IP address comparisons!
_________________________
There are two types of vessels, submarines and targets.

Top
#46944 - 2003-10-21 09:38 PM Re: Enumerating Computer Account Group Membership
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Use proper quote syntax please:

$prtpod1=\\server\share1

shouls be:

$prtpod1="\\server\share1"
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#46945 - 2003-10-21 09:41 PM Re: Enumerating Computer Account Group Membership
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Oh, and the binary logic used in your very first post is incorrect as you don't properly separate the AND and OR blocks from each other. At least the binary logic will not achieve what you try to do.
_________________________
There are two types of vessels, submarines and targets.

Top
#46946 - 2003-10-21 09:47 PM Re: Enumerating Computer Account Group Membership
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Why are you even using the IP range if you are mapping based on groups? Put the pc's in the group and map on that condition. Do they move to different subnets and exist in different groups?

tjcarst

Top
#46947 - 2003-10-21 09:52 PM Re: Enumerating Computer Account Group Membership
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
The IP address syntax could have location-based reasons as only the three specified computer should print to the particular printer and only if it is a nurse (and not a doctor). Might be a special-purpose printer.
_________________________
There are two types of vessels, submarines and targets.

Top
#46948 - 2003-10-21 10:24 PM Re: Enumerating Computer Account Group Membership
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Using IsInSubnet.udf http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000053

Try this:

code:
$ip=@IPADDRESS0
$networkid="10.1.1.0"
$subnetmask="255.255.255.0"
$answer=isinsubnet($ip,$networkid,$subnetmask)

$prtpod1="\\server\share1"
$prtpod2="\\server\share2"
$prtpod3="\\server\share3"
$prtpod4="\\server\share4"

call @scriptdir+'\computeringroup.udf'
call @scriptdir+'\isinsubnet.udf'

if ComputerInGroup('Bruns Pod')=1 AND IsInSubnet($answer)=1

if not PriMapState($prtpod1)
? "Status " $prtpod1 " not connected"
? @serror

$nul=AddPrinterConnection(\\server\$prtpod1)
? "Status - Added printer connection "$prtpod1
? @serror

$nul=SetDefaultPrinter($prtpod1)
? "Status - Default printer set "$prtpod1
? @serror

else exit 0

endif

endif

Edited to add call to isinsubnet.udf

tjcarst

[ 21. October 2003, 23:36: Message edited by: tjcarst ]

Top
#46949 - 2003-10-21 10:38 PM Re: Enumerating Computer Account Group Membership
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
code:
isinipsubnet("$answer")

is incorrect, just use the IsInSubnet call directly. And please don't use vars in strings (or quotes)!

[ 21. October 2003, 23:37: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#46950 - 2003-10-21 11:30 PM Re: Enumerating Computer Account Group Membership
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000053

At first I did have isinipsubnet, but this links shows isinsubnet.

I'll correct the syntax. Again. Sorry, I'm working on a million things and just thought I might be able to give Matt a little direction. It's apparent that I, too, am a newbie.

Top
#46951 - 2003-10-22 03:25 AM Re: Enumerating Computer Account Group Membership
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Download BinaryIP.udf and try this
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000030

Are you using a normal class a (255.0.0.0)10.0.0.0 subnet as a class C (255.255.255.0) network - 10.1.1.0/255.255.255.0?

code:
call @ScriptDir+'\BinaryIP.udf'
call @Scriptdir+'\ComputerInGroup.udf'

$prtpod1="\\server\share1"
$prtpod2="\\server\share2"
$prtpod3="\\server\share3"
$prtpod4="\\server\share4"

if ComputerInGroup('Bruns Pod')=1

if subnet("10.1.1.0", "10.1.1.0", "255.255.255.0") = 1

if not PriMapState($prtpod1)
? "Status " $prtpod1 " not connected"
? @serror

$nul=AddPrinterConnection(\\server\$prtpod1)
? "Status - Added printer connection "$prtpod1
? @serror

$nul=SetDefaultPrinter($prtpod1)
? "Status - Default printer set "$prtpod1
? @serror

endif

endif

endif


Top
#46952 - 2003-10-22 03:30 PM Re: Enumerating Computer Account Group Membership
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Now, what does the BinaryIP UDF have to do with the Subnet UDF as you don't include the Subnet UDF in your code?

Also, why do you jump back and forth between different UDFs, anyway? One time you use IsInSubnet(), another time you use BinaryIP(0/Subnet(). They both accomplish the same.
_________________________
There are two types of vessels, submarines and targets.

Top
#46953 - 2003-10-22 06:42 PM Re: Enumerating Computer Account Group Membership
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
No idea. Just trying to get something to work for Mike. I don't know why I try though, I can't get anything to work for me. [Confused]

Edited to add that the link for subnet.udf says BinaryIP is a requirement.

tjcarst

[ 22. October 2003, 18:44: Message edited by: tjcarst ]

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 262 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.063 seconds in which 0.02 seconds were spent on a total of 14 queries. Zlib compression enabled.

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