Page 1 of 2 12>
Topic Options
#24861 - 2002-07-11 06:50 PM Drive mapping according to server name or IP address?
Dax Offline
Fresh Scripter

Registered: 2002-01-04
Posts: 8
Loc: Mid West
I have 4 subnets in my network. I have a couple of managers who roam from subnet to subnet. When they log on, I would like to map their home directory back their primary server, but the other data shares to map to the local server.
So I need a logon to map according to the closest server. Do I do this by the server name or the IP address? I am very new to Kixtart and have not had a lot of available time to study up on it. [Frown]
If anyone could point me in the right direction, it would be greatly appreciated.

Dax
_________________________
Everything is okay in the end. If it's not okay, then it's not the end.

Top
#24862 - 2002-07-11 07:06 PM Re: Drive mapping according to server name or IP address?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
if you have subnets which differ clearly in IP, you can use that.
and also the servername.

like: if in ip-range, use this server.
also, you can select the subnet by the logonservers.
just what feels most comfortable?
_________________________
!

download KiXnet

Top
#24863 - 2002-07-11 07:13 PM Re: Drive mapping according to server name or IP address?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
These might help if you go the IP address way:
* IsInIPRange()
* CalcLogicalSubnet()
* Subnet()
* IsInSubnet()
_________________________
There are two types of vessels, submarines and targets.

Top
#24864 - 2002-07-11 09:26 PM Re: Drive mapping according to server name or IP address?
Dax Offline
Fresh Scripter

Registered: 2002-01-04
Posts: 8
Loc: Mid West
Your replys have been very infomative, so thank you.

Here is what I've tried today:

IF @IPADDRESS0 = " 10. 1. *. *"
USE m: "\\gbtsrv01\users"

If @IPADDRESS0 = " 10. 2. *. *"
USE n: "\\gbtsrv02\users"

ENDIF

and no luck, and suggestions?

[ 11 July 2002, 21:28: Message edited by: Dax ]
_________________________
Everything is okay in the end. If it's not okay, then it's not the end.

Top
#24865 - 2002-07-11 09:33 PM Re: Drive mapping according to server name or IP address?
Kdyer Offline
KiX Supporter
*****

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

Every IF has to have an ENDIF
code:
IF @IPADDRESS0 = " 10. 1. *. *"
USE m: "\\gbtsrv01\users"
ENDIF

If @IPADDRESS0 = " 10. 2. *. *"
USE n: "\\gbtsrv02\users"
ENDIF

Suggestion, you want to clean up the IP addressess using the following FAQ and specifically - IP Address Trimming.

HTH,

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

Top
#24866 - 2002-07-11 09:37 PM Re: Drive mapping according to server name or IP address?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Since when can you use wildcards?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#24867 - 2002-07-11 09:38 PM Re: Drive mapping according to server name or IP address?
Kdyer Offline
KiX Supporter
*****

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

You are right..

I was really trying to focus on the IP Address Trimming..

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

Top
#24868 - 2002-07-11 09:45 PM Re: Drive mapping according to server name or IP address?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Use any of the UDFs I mentioned to check for IP address ranges.
E.g.
code:
$IPAddress=@IPADDRESS0
$NetworkID='192.168.10.0'
$SubnetMask='255.255.255.224'
if IsInSubnet($IPAddress,$NetworkID,$SubnetMask)
use x: '\\server\share'
endif

_________________________
There are two types of vessels, submarines and targets.

Top
#24869 - 2002-07-11 09:46 PM Re: Drive mapping according to server name or IP address?
Dax Offline
Fresh Scripter

Registered: 2002-01-04
Posts: 8
Loc: Mid West
Thank you for the quick reply, but... I still dont understand. [Frown]
I'm sorry for sounding so stupid, I know nothing of scripting, and the triming doesnt make sense, where am I to put my IP information in the Trimming code?

Here is what I now have:

;LTRIM - TRIM THE LEADING SPACES FROM A STRING
;SUBSTR - RETURNS PART OF STRING: START POSITION, LENGTH
$1st = LTRIM(SUBSTR(@ipaddress0, 1, 3)) ; #ip#
$2nd = LTRIM(SUBSTR(@ipaddress0, 5, 3)) ; #ip# Get the IP# and assign it to $ipadr
$3rd = LTRIM(SUBSTR(@ipaddress0, 9, 3)) ; #ip#
$4th = LTRIM(SUBSTR(@ipaddress0, 13, 3)) ; #ip#
$ipadr = "$1ST.$2ND.$3RD.$4TH" ; #ip#

IF @IPADDRESS0 = " 10. 1. *. *"
USE M: "\\gbtsrv01\users"
ENDIF
If @IPADDRESS0 = " 10. 2. *. *"
USE N: "\\gbtsrv02\users"
ENDIF
_________________________
Everything is okay in the end. If it's not okay, then it's not the end.

Top
#24870 - 2002-07-11 09:49 PM Re: Drive mapping according to server name or IP address?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
So, really what you need to do is check the second octet.

$2nd = Val(SUBSTR(@ipaddress0, 5, 3))

See also, the FAQ

Topic: IP Address trimming
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#24871 - 2002-07-11 09:56 PM Re: Drive mapping according to server name or IP address?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
This octect-checking will only work if you have subnet mask like 255.0.0.0, 255.255.0.0, and 255.255.255.0. If your subnet mask is different then you will need to check the IP address against the network ID and the subnet mask.

For example, a network 192.168.10.0 with subnet mask 255.255.255.192 includes IP addresses 192.168.10.1-192.168.10.63. This canot be checked for by just comparing octets.
_________________________
There are two types of vessels, submarines and targets.

Top
#24872 - 2002-07-11 09:59 PM Re: Drive mapping according to server name or IP address?
Dax Offline
Fresh Scripter

Registered: 2002-01-04
Posts: 8
Loc: Mid West
Would this work better?

IF @LSERVER = "gbtsrv01"
USE m: "\\gbtsrv01\users"
ENDIF
If @LSERVER = "gbtsrv02"
USE n: "\\gbtsrv02\users"
ENDIF
_________________________
Everything is okay in the end. If it's not okay, then it's not the end.

Top
#24873 - 2002-07-11 10:00 PM Re: Drive mapping according to server name or IP address?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Jens,
Made the assumption that since it is a class 'A' address that it is probably subnet'd with a class 'B' mask.

Dax,
Perhaps you missed the subtle hit in my post. You cannot use wildcards. You can do string compares or, if converted to integer with Val(), number compares.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#24874 - 2002-07-11 10:01 PM Re: Drive mapping according to server name or IP address?
Kdyer Offline
KiX Supporter
*****

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

That would be a matter of preference..

What is m: and n: ?

If these are user's home drives, you may want to use IF INGROUP. If they are application drives, no problem.

Thanks,

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

Top
#24875 - 2002-07-11 10:02 PM Re: Drive mapping according to server name or IP address?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Dax,
You could use @LSERVER but there's no guarantee that the sever to service the logon request will be the "nearest".
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#24876 - 2002-07-11 10:16 PM Re: Drive mapping according to server name or IP address?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Les:

I made no assumptions about her network layout, that's why I stated a general case.
_________________________
There are two types of vessels, submarines and targets.

Top
#24877 - 2002-07-11 10:29 PM Re: Drive mapping according to server name or IP address?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... since Dax was checking the 2nd octet... [Wink]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#24878 - 2002-07-11 11:13 PM Re: Drive mapping according to server name or IP address?
Dax Offline
Fresh Scripter

Registered: 2002-01-04
Posts: 8
Loc: Mid West
Your right LLigetfa, the @lserver will not garantee the right server.

Will this code still need UDF functions to go along with it? And do I need the spacing in my IP addresses, or can I type them in normal?

code:
  
SELECT
CASE (@IPADDRESS0 >= "10. 1. 1. 0") AND (@IPADDRESS0 < "10. 1. 1.255") $Vpn =

"No"
CASE (@IPADDRESS0 >= "10. 2. 1. 0") AND (@IPADDRESS0 < "10. 2. 1.255") $Vpn =

"No"
CASE (1) $Vpn = "Yes"
ENDSELECT

IF ($Vpn = "No")
CALL "iowafalls.kix"
ELSE
CALL "ackley.kix"
ENDIF

_________________________
Everything is okay in the end. If it's not okay, then it's not the end.

Top
#24879 - 2002-07-11 11:39 PM Re: Drive mapping according to server name or IP address?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
This works, too:
code:
$octet=split(@IPADDRESS0,'.')
SELECT
CASE val(trim($octet[1]))=1 and val(trim($octet[2]))=1
$Vpn = "No"
CASE val(trim($octet[1]))=2 and val(trim($octet[2]))=1
$Vpn = "No"
CASE 1
$Vpn = "Yes"
ENDSELECT
IF $Vpn = "No"
CALL "iowafalls.kix"
ELSE
CALL "ackley.kix"
ENDIF

Basically, it splits the IP address into four octets 0-3 and then checks the values for octet 1 and 2.

[ 11 July 2002, 23:42: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#24880 - 2002-07-12 12:03 AM Re: Drive mapping according to server name or IP address?
Dax Offline
Fresh Scripter

Registered: 2002-01-04
Posts: 8
Loc: Mid West
I am far from giving up, so far... I think Kixtart is powerfull, and has lots of potental for me, but... this is what I ended up doing:
code:
IF EXISTS ("c:\kix.txt")
USE P: \\gbtacksrv01\apps /persistent:no
ELSE
USE P: \\gbtsrv01\apps /persistent:no
ENDIF

USE S: \\gbtacksrv01\shared /persistent:no
USE LPT1: \\gbtacksrv01\ackmitalj /persistent:no

I e-mailed people in one of my remote locations with kix.txt attatched and told them to save it to thier local C: and this works great, so... it solves my problem for now, but I will still be on these boards learning as much as I can about this scripting tool. Thank you ALL for your replies. [Smile]
_________________________
Everything is okay in the end. If it's not okay, then it's not the end.

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 2419 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.08 seconds in which 0.032 seconds were spent on a total of 13 queries. Zlib compression enabled.

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