Page 1 of 1 1
Topic Options
#70422 - 2002-10-01 12:19 AM inventory for certain peeps on certain classC
Manimal Offline
Getting the hang of it

Registered: 2000-04-04
Posts: 96
Loc: Oregon City, OR. USA
I've got an inventory script - which is still a work in progress - that I want to only run for a user if they are in their native network.

For example. UserA belongs to DeptA and roams between offices A, B, and C which all have their own ClassC subnets. User A could also visit and work from office D which belongs to a diff department. Right now the inventory script would run at login and I'd get an entry for a machine belonging to DeptB in Dept A's area.

I need the script to identify the classC of the current station (already done), department which the person belongs to (done via PrimaryGroup), and only run the inventory piece if the class C matches a valid entry for that department.

I was thinking of using an array or a select statement of valid Class C's for each department but I've got 40 departments to deal with.

Can anyone think of an easy way to organize this? If you need more description let me know.

Thanks,
Chris
_________________________
Chris Fricke
Clackamas County

Top
#70423 - 2002-10-01 12:29 AM Re: inventory for certain peeps on certain classC
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
for each dep you can make a var:
$dep_name={c-class}

and then against primary group (it has to be the same name as the var):
code:
$nul=execute("if $$"+$primarygroup+"=$current_class gosub 'inventory' endif")

then, if there is more allowable c-classes for some deps, you can do it as:
code:
$nul=execute("if instr($$"+$primarygroup+",$current_class) gosub 'inventory' endif")

easy? [Wink]
_________________________
!

download KiXnet

Top
#70424 - 2002-10-01 04:38 AM Re: inventory for certain peeps on certain classC
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Use an .INI file
code:
[Department A]
Subnet=123.123.123.123
[Departmetn B]
Subnet=111.111.111.111

and use READPROFILESTRING('subnet.ini',@PRIMARYGROUP,'Subnet') to pull the users subnet from the .INI file. Compare with the actual subnet via UDF (IsInSubnet or similar), "kick it up a notch", and done. [Wink]
_________________________
There are two types of vessels, submarines and targets.

Top
#70425 - 2002-10-01 04:40 AM Re: inventory for certain peeps on certain classC
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
 
ini-dude has waken up [Razz]
 
_________________________
!

download KiXnet

Top
#70426 - 2002-10-01 04:47 AM Re: inventory for certain peeps on certain classC
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
[Mad] Hey! [Mad] If you do that again I start a lecture about why I think that a .INI file is like a relational database! [Eek!] [Confused] [Cool]
_________________________
There are two types of vessels, submarines and targets.

Top
#70427 - 2002-10-01 04:52 AM Re: inventory for certain peeps on certain classC
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh?
so, my comment was pretty much making you mad and somewhat confused, amazed and cool?
nice work on graemlins [Big Grin]

actually, now as I put my brains back on, I can admit that ini's have their benefits.
just haven't used to use them everywhere...
 
_________________________
!

download KiXnet

Top
#70428 - 2002-10-01 04:56 AM Re: inventory for certain peeps on certain classC
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Yes, in the absence of a native dictionary object in KiXtart it's pretty much the next best thing.
_________________________
There are two types of vessels, submarines and targets.

Top
#70429 - 2002-10-01 05:03 AM Re: inventory for certain peeps on certain classC
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Well I think that the hash (Associative Array, Dictionary Object) would be the best approach. The INI file work well too.

Pseudo Hash UDFs

Use my UDF CalcLogicalSubnet (IP, SNmask) or one of the others in the UDF Library to determine the logical subnet. (This is not necessary for just three subnets. But if your network grows and you start to allocate only a small number of addresses per location, this approach can grow with you.)

[ 01. October 2002, 05:18: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#70430 - 2002-10-01 05:15 AM Re: inventory for certain peeps on certain classC
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
First off, I gotta say, you guys are a hoot! Jens with his INIs, Howard and his Hash, and Jooel, well he's Jooel.

Manimal,
I don't know how you are planning to pull together all the inventory info but wouldn't the subnet/dept already be in there? Just need to compare with what you've got. If you have nothing, then you don't know what subnet/dept is the true home.

So basically, look at the many subnet calculating UDFs and pick the one that best suits.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#70431 - 2002-10-01 05:16 AM Re: inventory for certain peeps on certain classC
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
when you did catch 3000?

congrats!

{edit}
wmi-scriptomatic seems to be the 3M post
 

[ 01. October 2002, 05:17: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#70432 - 2002-10-01 05:19 AM Re: inventory for certain peeps on certain classC
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Guess that would've been about three posts ago.

Thanks... now, if I could only get another vote to catch you. [Wink]

{edit}DOH! two votes. [Eek!]

[ 01. October 2002, 05:20: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#70433 - 2002-10-01 06:51 PM Re: inventory for certain peeps on certain classC
Manimal Offline
Getting the hang of it

Registered: 2000-04-04
Posts: 96
Loc: Oregon City, OR. USA
still running an old version of kix so the UDFthingy won't work.

Several departments have multiple class C's
DeptA
10.32.1
10.32.2
10.32.3

DeptB
10.32.4

etc

so...

code:
:SetUniversalVars
$oct1 = LTRIM(SUBSTR(@ipaddress0, 1, 3))
$oct2 = LTRIM(SUBSTR(@ipaddress0, 5, 3))
$oct3 = LTRIM(SUBSTR(@ipaddress0, 9, 3))
$classB = $oct1 + "." + $oct2
$classC = $oct1 + "." + $oct2 + "." + $oct3

:GroupDetect
select
case @primarygroup = "deptA"
;mapdrive, set vars, yaddayadda
$arraytotal = 3
DIM $subnet[$arraytotal]
$subnet[0] = 10.32.1
$subnet[1] = 10.32.2
$subnet[2] = 10.32.3
goto "techstuff"
case @primarygroup = "deptB"
;mapdrive, set vars, yaddayadda
$arraytotal = 1
DIM $subnet[$arraytotal]
$subnet[0] = 10.32.4
goto "techstuff"
case 1
endselect

:TechStuff
;--- inventory ---
$nb = 0
DO
if $ClassC = $subnet[$nb]
call "inventory.kix"
endif
$nb = $nb + 1
UNTIL $nb = $arraytotal
;--- set email profiles, citrix setings, Ras detect, etc ---

Think that's simple enough?

Thanks,
Chris

[ 01. October 2002, 18:52: Message edited by: Manimal ]
_________________________
Chris Fricke
Clackamas County

Top
#70434 - 2002-10-01 06:56 PM Re: inventory for certain peeps on certain classC
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Shouldn't you put your strings in quotes?

$subnet[0] = "10.32.1"
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#70435 - 2002-10-02 12:19 AM Re: inventory for certain peeps on certain classC
Manimal Offline
Getting the hang of it

Registered: 2000-04-04
Posts: 96
Loc: Oregon City, OR. USA
yes you are correct - but in my defense it's just a sample for concept [Razz]
_________________________
Chris Fricke
Clackamas County

Top
#70436 - 2002-10-03 12:19 AM Re: inventory for certain peeps on certain classC
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
how old version you are using?
as you have arrays and all!
_________________________
!

download KiXnet

Top
#70437 - 2002-10-03 12:30 AM Re: inventory for certain peeps on certain classC
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
btw, you can change:
code:
$arraytotal  = 3
DIM $subnet[$arraytotal]
$subnet[0] = 10.32.1
$subnet[1] = 10.32.2
$subnet[2] = 10.32.3

to just:
code:
DIM $subnet
$subnet = "10.32.1","10.32.2","10.32.3"

might simplify a little.
if you are not using the classC elsewhere, you don't need array at all, just remove this:
code:
:TechStuff
;--- inventory ---
$nb = 0
DO
if $ClassC = $subnet[$nb]
call "inventory.kix"
endif
$nb = $nb + 1
UNTIL $nb = $arraytotal

and change the lines to:
code:
;subnets:
$subnet = "10.32.1","10.32.2","10.32.3"

;if correct, do inventory:
if instr($subnet,$ClassC)
call "inventory.kix"
endif

cuts almost half of your code... (does it?)
 
_________________________
!

download KiXnet

Top
#70438 - 2002-10-07 08:32 PM Re: inventory for certain peeps on certain classC
Manimal Offline
Getting the hang of it

Registered: 2000-04-04
Posts: 96
Loc: Oregon City, OR. USA
I will re do the array - much cleaner but I need to keep the $classC as it it referenced elsewhwere (several places actually) for different functions

thanks all - I love this place!
_________________________
Chris Fricke
Clackamas County

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
0 registered and 1471 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.178 seconds in which 0.148 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