#46934 - 2003-10-17 08:05 PM
Enumerating Computer Account Group Membership
|
Mike Pratt
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
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
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
|
|
|
|
#46938 - 2003-10-17 08:52 PM
Re: Enumerating Computer Account Group Membership
|
Mike Pratt
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
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
|
|
|
|
#46941 - 2003-10-21 08:44 PM
Re: Enumerating Computer Account Group Membership
|
Mike Pratt
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
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.
tjcarst [ 21. October 2003, 21:44: Message edited by: tjcarst ]
|
Top
|
|
|
|
#46944 - 2003-10-21 09:38 PM
Re: Enumerating Computer Account Group Membership
|
Howard Bullock
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"
|
Top
|
|
|
|
#46946 - 2003-10-21 09:47 PM
Re: Enumerating Computer Account Group Membership
|
tjcarst
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
|
|
|
|
#46948 - 2003-10-21 10:24 PM
Re: Enumerating Computer Account Group Membership
|
tjcarst
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
|
|
|
|
#46950 - 2003-10-21 11:30 PM
Re: Enumerating Computer Account Group Membership
|
tjcarst
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
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
|
|
|
|
#46953 - 2003-10-22 06:42 PM
Re: Enumerating Computer Account Group Membership
|
tjcarst
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.
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 262 anonymous users online.
|
|
|