#203086 - 2011-09-15 02:33 PM
new to kixtart - need help with location/subnet based actions
|
tonymorin
Just in Town
Registered: 2011-08-31
Posts: 3
Loc: indiana
|
hey guys im really new to kixtart and im having trouble finding a good why to filter out shourtcuts by ip or subnet. Problem: i have main facility in indiana that needs MSDS shortcut that only pertains to that facility. one more facility in north Carolina that needs another different MSDS shortcut icon to only display on the users desktops. both file systems and icons are hosted local in indiana server.
I have been trying some
@ipaddress
trying to using cidr 10.0.3.0/24
I think it might be out of the range of my skill as of right now. please if anyone can help Thanks Tony
Edited by Mart (2011-09-15 02:49 PM) Edit Reason: Updated title to state the issue.
|
Top
|
|
|
|
#203088 - 2011-09-15 03:55 PM
Re: new to kixtart - need help with location/subnet based actions
[Re: tonymorin]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4400
Loc: New Jersey
|
@IPADDRESS is text based and a messy way of mananging IP info..
This will convert the IP address string to a normal IP address without extra spaces.$MyIP = Join(Split(@IPADDRESS, ' '), '') Now that you have an IP address, you can use one of several UDFs that can perform CIDR calculations and tell you which subnet that IP address belongs to. Once you know which subnet you are a member of, you can easily apply the "one or many" logic to create the MSDS shortcuts.
Here's some PseudoCode to give you an idea of how it works. First, you need a table of network subnet ranges in an array.$SiteSubnets = '192.168.0.0/22','192.168.4.0/23','192.168.6.0/23' Note that this array aggregates the individual subnets at a site - the first has networks 0-3, the second 4-5, and the third 6-7. We aren't interested so much in the subnet but the SITE where the subnet exists! Here's some basic working code. You'll need the IsInSubnet UDF, either from KORG or my library. Call '\KixLib\IsInSubnet.udf'
; define the subnets at each site
$aSiteSubnets = '192.168.0.0/22','192.168.4.0/23','192.168.6.0/23'
; Define each of the URL strings
$aURLs = 'URL1', 'URL2', 'URL3'
; Define which URLs are assigned to each site. In this example, site 0 gets URL0, Site 1 gets URL 0 and 1, etc..
$aSiteURLs = '0', '0,1', '2'
; Eliminate spaces in the IP macro
$MyIP = Join(Split(@IPADDRESS0, ' '), '')
; Use a UDF to determine which subnet the current IP resides in.
$aMySite = isinsubnet($MyIP,$aSiteSubnets)
; If no error, get the Site ID
If Not @ERROR
'My IP: ' $MyIP ? ; debug message
$Site = AScan($aMySite, 1)
'My Site ID: ' $Site ? ; debug message
'URLs: ' $aSiteURLs[$Site] ? ; debug message
$URL_List = Split($aSiteURLs[$Site], ',')
For Each $Url in $URL_List
$aURLs[$Url] ' is being defined' ?
; Use a UDF to create the shortcut to the URL
Next
Else
'IP is not in any Site network!' ?
EndIf
By using the UDF and sticking with CIDR calculations, you can aggregate subnets by site without lots of "InStr()" calls to test for each individual subnet.
BTW - Welcome to KORG!
Glenn
_________________________
Actually I am a Rocket Scientist!
|
Top
|
|
|
|
#203090 - 2011-09-15 06:03 PM
Re: new to kixtart - need help with location/subnet based actions
[Re: Glenn Barnas]
|
tonymorin
Just in Town
Registered: 2011-08-31
Posts: 3
Loc: indiana
|
wow thx for the fast solutions guys. as i have been thinking about it. we do have defined ip ranges . so could i say some like...
if 10.0.5.0> then MSDS shourtcut A Eles do MSDS shourtcut b
any thoughts? thx again guys
|
Top
|
|
|
|
#203091 - 2011-09-15 08:26 PM
Re: new to kixtart - need help with location/subnet based actions
[Re: tonymorin]
|
ShaneEP
MM club member
   
Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
|
There are a ton of ways to do it, as they pointed out above...this would probably work...but not as fail safe as glenn's suggestion.
If Left(Join(Split(@IPADDRESS0, " "),""),6) = "10.0.5"
MSDS A
Else
MSDS B
Endif
|
Top
|
|
|
|
#203094 - 2011-09-16 03:12 PM
Re: new to kixtart - need help with location/subnet based actions
[Re: ShaneEP]
|
tonymorin
Just in Town
Registered: 2011-08-31
Posts: 3
Loc: indiana
|
i dont think i got this right....sorry...im new to this..CLS here is just a small amount of what im putting in..??
DIM $CommonOF DIM $CommonSH DIM $dev
$CommonOF = "True" $CommonSH = "False"
If Left(Join(Split(@IPADDRESS0, " "),""),6) = "10.0.5" copy "F:\IT\Shortcuts\MSDS-Mount Airy.lnk" "C:\documents and settings\all users\desktop" Else copy "F:\IT\Shortcuts\MSDS-Fort Wayne.lnk" "C:\documents and settings\all users\desktop" Endif
IF @USERID = "bob" or @USERID="bob2" or @USERID="bob3" or @USERID="bob4" or @USERID="bob5" or @USERID="bob6" USE f: /DELETE USE i: /DELETE USE n: /DELETE USE o: /DELETE USE p: /DELETE USE q: /DELETE USE r: /DELETE USE s: /DELETE USE t: /DELETE USE u: /DELETE USE v: /DELETE
Edited by tonymorin (2011-09-16 04:38 PM)
|
Top
|
|
|
|
#203096 - 2011-09-16 03:21 PM
Re: new to kixtart - need help with location/subnet based actions
[Re: Glenn Barnas]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4400
Loc: New Jersey
|
Apparently, you've got data sprinkled throughout your script! Ahhhgh! 
Unless your company has 5 or fewer people, having user-specific settings in your login script is a maintenance nightmare. AD Groups, my friend, are your BEST friend. If InGroup(groupname) do stuff... EndIf We usually create an OU called AccessControls, and create "AC-sharename" groups. These groups control modify access to various folders. Adding "-RO" to the sharename indicates READ access only. It's easy to maintain - and folders have at most 5 permissions set - Admins, System, Owner, AC-share, and (optionally) AC-share-RO. Granting or revoking permission requires only one group edit.
Also, take a look at the UDFs to create shortcuts. Copying a .lnk file may not have the same logical reference on the target computer. Creating the link fresh via the UDF will insure that the .LNK points to the right target, whether local or remote.
Glenn
_________________________
Actually I am a Rocket Scientist!
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 323 anonymous users online.
|
|
|