Kixtart IP address based login script


Does anyone know where I can find a sample Kixtart login script for IP based mappings?  What I would like to do is have the script look at the IP address of the PC, then set it to map drives to the server in the same subnet as the PC, rather than where the user account is based out of in Active Directory.  We have alot of users who move around to different buildings, but we don't want them mapping to servers in other buildings even if their account may be in a different building.  I already have the Kixtart software to get started.

Thanks in advance for your help.
Who is Participating?
oBdAConnect With a Mentor Commented:
The code above will NOT return a subnet. It's just looking at the third and fourth octett. A subnet is still calculated by a logical and of the IP address and the net mask.
Here's an example that will calculate the real subnet, including a case statement for the different locations that should get you going:

Dim $SubnetArray[3], $ArrayMask[3]
? "Getting IP information ..."
$SubnetArray = Split(EnumIPInfo(0, 0), ".", -1)
$MaskArray =  Split(EnumIPInfo(0, 1), ".", -1)
for $i = 0 to 3
  $SubnetArray[$i] = Val($SubnetArray[$i]) & Val($MaskArray[$i])
$Location = "Subnet-" + $SubnetArray[0] + "." + $SubnetArray[1] + "." + $SubnetArray[2] + "." + $SubnetArray[3]
  case ($Location = "Subnet-")
    ? "Current subnet:"
    use X: "\\ServerOne\SomeShare"
  case ($Location = "Subnet-")
    ? "Current subnet:"
    use X: "\\ServerTwo\SomeShare"
;Establishes $location variable, determined by subnet
$address = @IPADDRESS0
$subnet = SubStr($address,9,3)
$subnet1 = SubStr($address,13,3)
Case $subnet = "xxx" And $subnet1 >= "xxx" And $subnet1 <= "xxx"
$location = servername-1
"net use d: \\" & $location &"\" & @username &" /persistent"
Case (($subnet = "xxx" And $subnet1 >= "xxx" And $subnet1 <= "xxx") $location = servername2
"net use d: \\" & $location &"\" & @username & " /persistent"

See the link

For more details.
miket71Author Commented:
Thanks for the reply.  Now I was wondering if you can help explain some of the variables and meanings to help get me started.

In an example I have, I would be using a PC on a 10.1.1.X subnet, so I would want it to map to \\SERVERone\SHAREone which is also on a 10.1.1.X subnet.  My location for 10.1.1.X subnet would be called LOCATIONone.

I'm not quite sure how the Address, Subnet, and Locations I use would fit into the script, as I'm starting from scratch here.  I have 13 locations altogether, but with a little more help for the first location in the script, I should be able to add the rest of them in by myself, hopefully.
miket71Author Commented:
Great, thanks very much for your help.  We will be adding about 13 more subnets to the script so that the IP address of the PC will determine what server and share(s) it will map to.  We have some users who move around to different buildings in the course of a week, so this will come in very handy to make any PC map to and run the database applications based on the IP address/subnet of the PC/building where they are, and not where their login account is in Active Directory.  I will keep you posted on the results.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.