Page 1 of 1 1
Topic Options
#189381 - 2008-09-03 05:41 AM Compare home drive location with logon subnet
Dunit Offline
Fresh Scripter

Registered: 2003-12-10
Posts: 5

Hi Everyone,

I'm trying to achieve something here but am not sure of the best way to go about it. Basically the situation is that my workplace employs a lot of people who move from office to office on a regular basis. I'm in Australia so the geographic distances between the offices are quite large (Perth to Melbourne is over 3,000km for example).

Anyway IT is not always told that a user has moved across the country and we only find out when the user calls to complain about system speed or logon time being slow. It's obviously because they are downloading their roaming profile and using their home drive over the WAN (fairly slow links).


What I'd like to do is something like the following, though I am open to suggestions:


- Define a list of home drive servers
- Determine the IP address (and therefore subnet) of the user logging on.
- Extract the users home location in AD and put result into a variable (would dsget be appropriate or is there a better way?)
- Use split to strip the servername from the variable, with slashies as the delimiter. Turning "\\servername\share" into just "servername"
- IF the user is in a particular subnet (say Melbourne's subnet .208) and their servername is a server in Perth ("Perthserver") then do <action> like write a log or pop up a messagebox (not too fussed what the action is yet).


I already have this code which extracts the IP address quite nicely:

 Code:
; Set IP address in a human friendly format
$ipa = LTRIM(SUBSTR(@IPADDRESS0,1,3))
$ipb = LTRIM(SUBSTR(@IPADDRESS0,5,3))
$ipc = LTRIM(SUBSTR(@IPADDRESS0,9,3))
$ipd = LTRIM(SUBSTR(@IPADDRESS0,13,3))
$ipNO = $ipa + "." + $ipb + "." +$ipc + "." +$ipd


Existing code already maps some local common drives accordingly by using the 3rd octet variable "$ipc":

 Code:
SELECT
CASE $ipc = "231" 
  USE T: '\\SERVERNAME\TEMP'
CASE $ipc = "208" 
  USE T: '\\SERVERNAME\TEMP'
ENDSELECT


..etc

So it's the above pseudocode that I'm looking for a bit of advice on. If anyone has any ideas feel free to post them - you may have a totally different approach which is no worries at all. I've just been told to "Make the logon script tell us whether the user is logging on at a site where their home drive (and maybe profile) is not located"!

Thanks for your advice!

Andrew.

Top
#189382 - 2008-09-03 08:19 AM Re: Compare home drive location with logon subnet [Re: Dunit]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
You are on the right track.

You have defined the criteria.

  • Obtain the users current subnet
    Read the AD account info to find the defined home share / profile location
    Notify an individual(s) about the discrepency.


You already have the subnet being retrieved, so mark off the first item.
There are many different ways to read the AD Account information, I prefer usng LDAP lookups (There are many UDF's available here to help you with that)
I would send an Email to whomever would be moving the users data and leave it at that.

This is but just one idea of how to implement what you are thinking of.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#189383 - 2008-09-03 08:31 AM Re: Compare home drive location with logon subnet [Re: Gargoyle]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
To elobarate

 Code:
$RetrievedData = ;LDAP Lookup with an existing UDF such as LDAP Query
$Server = Split($RetrievedData,"\")[0]
If ReadProfileString ("C:\MasterServerList.ini",$Server,"IP") <> $IP
 ;Create an email message to send out to someone via Blat
EndIf


INI file structure

[ServerA]
IP = 201

[ServerB]
IP = 202

[ServerC]
IP = 203
_________________________
Today is the tomorrow you worried about yesterday.

Top
#189385 - 2008-09-03 12:08 PM Re: Compare home drive location with logon subnet [Re: Gargoyle]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
My pre-built login script already supports this, on several levels.

If you know where the user is globally, you can define the profile to run the login script from a subfolder. IE - "au\kix32 au\kixtart.kix" for users in Oz, "eu\kix32 eu\kixtart.kix" for users in Europe, and "na\kix32 na\kixtart.kix" for users in North America.

Now that globalization issues are resolved, you can use AD Sites, department OUs, and groups to control specific resources. Some might need to be available no matter where the user is. This is basic stuff - if a user is a member of a group/OU, map/don't map, or map if not a member configurations are all possible.

Finally, you can define regional settings to rewrite the mapping path. Lets say you have 50 shops across Oz, each has a server for local storage. You can define the same share name on each server. The login script would use Path Rewrite technology to change the server name, or even the entire path that's mapped to a drive letter, based on OU, AD Site, or IP Subnet.

In addition to mapping drives/printers, the script can display messages and run commands (even call kix scripts with a common environment!) using the same Path Rewrite technology.

If you want to write your own code, I'd convert the IP to a standard string without spaces, and use an IsInSubnet() to determine which network your're in. The GetNetInfo() UDF on my site will be very helpful - you feed it an IP, it opens a subnets.inf file that lists your networks and other data, and it returns the specified field when it finds a subnet match. You can use that to easily translate IP addresses to server names or even entire UNC paths.

I'd definitely NOT put your IP/URL/Server data in your script, since every time you open your script to change data, you run the risk of damage. Keep your mapping data outside your script - your environment's way beyond the "mom & pop shop" mentality of combined data & script.

Glenn

BTW - if you want to try my login script with IP rewrites, PM me - It's a recent update and not through final testing. It should be complete this week, but I can get you an early release.
_________________________
Actually I am a Rocket Scientist! \:D

Top
#189413 - 2008-09-04 12:44 AM Re: Compare home drive location with logon subnet [Re: Gargoyle]
Dunit Offline
Fresh Scripter

Registered: 2003-12-10
Posts: 5

Hi Gargoyle,

Great suggestions - I'll look further into what you have suggested. And the email thing is a really good idea. I'll probably make it send an email to the service desk. Users tend to pay very little attention when messages are directed at them \:\)

Thanks again!

Top
#189414 - 2008-09-04 12:54 AM Re: Compare home drive location with logon subnet [Re: Glenn Barnas]
Dunit Offline
Fresh Scripter

Registered: 2003-12-10
Posts: 5

G'day Glenn,

Thanks very much for your post - really informative stuff! I'd really be interested in your script to get some ideas so I'll PM you on that.

Suggestion noted on the IP/URL data not in the script itself and I'll look at some of the UDF's and methods you mentioned.

I do use the same share names on all my servers so that will make things a lot easier. The server names have undergone a few naming convention changes over the years with company name changes and business unit changes but the shares have remained the same on all boxes (I have around 70 servers around Oz, tho not all of them are file servers obviously!).

Thanks again to all for suggestions - my Kix scripting is only fairly basic, tho I do already use a few things like INGROUP and other basic methods.

Thanks again \:\)

Top
#189433 - 2008-09-04 12:56 PM Re: Compare home drive location with logon subnet [Re: Dunit]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
My initial thought was to just set up everyone's home directory on every home server. Use rsync to keep them updated. This was tempered by the thought of how to determine which server was master. I then thought you could write a logoff script that would write to a local ini file. That way, each server would run rsync only on the home directories that it is master for. You could greatly reduce the amount of copying by only rsyncing the home directories of the people that routinely move. Most people probably just stay at their home office and you wouldn't have to worry about rsyncing them. Create a group for rsync. Even if a person is just making a one-time trip, you could add him/her to the group; rsync up the home directory a day or two before travel; and then remove from the group after return and manually (or part of a script) delete the home directory on the other servers to free up space.

Regards,

Brad V


Edited by BradV (2008-09-04 05:25 PM)
Edit Reason: Missed a word :)

Top
#189437 - 2008-09-04 04:26 PM Re: Compare home drive location with logon subnet [Re: BradV]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Hey there Mr Goyle,

If you're familiar with RSync, you should check out Unison. It's a bi-directional version of RSync. I use it to keep my software deployment folders in sync between the HQ sites and branch offices. I do force a directional sync, though - outbound for apps and inbound for logs, but do use it in bidirectional mode for other tasks. Fully scriptable, too!

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 259 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.058 seconds in which 0.024 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