Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Pete Sass
  Where is Pete Sass?
 Marathon, Ontario
 Canada
 Pete Sass
 To: Khurram Tahir
  Where is Khurram Tahir?
 Karachi
 Pakistan
 Khurram Tahir
 Tags
Subject: RE: Set default to in Multiuser
Thread ID: 331393 Message ID: 331424 # Views: 29 # Ratings: 0
Version: Visual FoxPro 9 Category: Projects and Design
Date: Thursday, December 29, 2011 7:47:07 PM         
   


Hi,

First off as Tushar advised in a previous thread the UNC should work for you on both server and workstations.
I generally use the UNC approach for a variety of reasons.... please read on below.
1. I do not have to contend with any drive mappings at all on any workstations or server.
2. If I am running under active directory I do not have to fiddle with Netlogin user group scripting to map the required drives.
3. I can setup the network share as a hidden share so the share cannot be seen across the network or navigated to by the users. You do this by creating the network share name with a $ sign after the name. You do need to assign the user/groups read-write access to the server folder where the data resides for VFP native database backends. So you should have the required user/groups in the Security permissions at an NTFS level and in the Sharing tab - Permissions button have the required user/groups assigned as Change and Read permissions.
4. With a mapped drive the LAN users could navigate to your application and data folders and accidently delete, rename or drag and drop the folder or folders by accident, killing anyone on the LAN running you app until you find out what happened and fix it... so why not just side-step this problem completely and use a hidden network share and a UNC to point to the server share location folder or folders.

So above you can see the kind of lock down security and problems you can avoid with just a little up front planning!


A few more options for your consideration. . .

In your Main.prg startup program you could call a UDF to test for the UNC path being available prior to attempting to set the default to command.

A very simply UDF like below in your project saved as a .prg would do this for you... see below:

* --- CheckUNC.prg
* --- Check if UNC exists or is avalable.
* --- Coded as simply function to return .T. or .F.
* --- depending upon the existance of the UNC path
* --- existing.
* --- Syntax: llUNCexists = CHECKUNC("UNC Path Name")
* --- Note the local logical memvar llUNCexists will hold the
* --- value of .T. or .F. depending if your UNC Path Name exists.
PARAMETERS lcUNCstring
IF DIRECTORY(lcUNCstring)
   RETURN .T.
ELSE 
   RETURN .F.
ENDIF



So in your Main.prg you calling code would look like below:
llUNCexists = CHECKUNC("UNC Path Name")  && Enter your real UNC path here
This call would be towards the top of the code in your Main.prg prior to the SET DEFAULT TO command.
* --- Test if the UNC path exists.
If llUNCexists = .F.
   = MessageBox("Your server is currently un-available, contact your IT administrator!",0+16,"Server Not Available")
   CLEAR EVENTS
   CLOSE DATABASES ALL
   QUIT
Endif



You could also go with an ON ERROR trap prior to issuing the SET DEFAULT TO command and test things this way.

llUNCError = .F.
ON ERROR llUNCError = .T.
SET DEFAULT TO \\DELLWEBS-001\Backup_WKSTN  && Example UNC is my server name and one of my network shares.
IF llUNCError = .T.
  = MessageBox("Your server is currently un-available, contact your IT administrator!",0+16,"Server Not Available")
   CLEAR EVENTS
   CLOSE DATABASES ALL
   QUIT
Endif


So you can see there are many ways to do what you want to do and all are very easy to impliment in a VFP program!

The ping command test if the server is on the network, the function shown above and the ON ERROR trap tests for the existance of your UNC path to the server.

If you really wanted to take this entire process to another level "in cases where network infastructure is not the best", then in all your VFP cursors use Buffering Mode-5. Then you can call something like the above CheckUNC.prg function to re-test the network connectivity to your targeted UNC prior to issuing any TABLEUPDATE() command. If the UDF function returns .F. you can issue the TABLEREVERT() VFP call and provide a MessageBox to your users that server connectivity has been lost and gracefully close down your VFP application until the problem has been resolved.

Don't forget that a FLUSH command after a TABLEUPDATE() as this can reduce VFP table corruption issues across a LAN.


Pete "the IceMan", from the Great White North of Canada.
www.marathongriffincomputers.com

ENTIRE THREAD

Set default to in Multiuser Posted by Khurram Tahir @ 12/29/2011 4:53:49 PM
RE: Set default to in Multiuser Posted by tushar @ 12/29/2011 5:00:03 PM
RE: Set default to in Multiuser Posted by Khurram Tahir @ 12/29/2011 5:03:37 PM
RE: Set default to in Multiuser Posted by tushar @ 12/29/2011 5:24:30 PM
RE: Set default to in Multiuser Posted by Khurram Tahir @ 12/29/2011 5:33:44 PM
RE: Set default to in Multiuser Posted by tushar @ 12/29/2011 5:38:34 PM
RE: Set default to in Multiuser Posted by Khurram Tahir @ 12/29/2011 6:06:09 PM
RE: Set default to in Multiuser Posted by tushar @ 12/29/2011 7:42:31 PM
RE: Set default to in Multiuser Posted by Khurram Tahir @ 12/30/2011 3:49:13 AM
RE: Set default to in Multiuser Posted by tushar @ 12/30/2011 5:25:45 AM
RE: Set default to in Multiuser Posted by Koen Piller @ 12/29/2011 5:43:40 PM
RE: Set default to in Multiuser Posted by Khurram Tahir @ 12/29/2011 6:11:49 PM
RE: Set default to in Multiuser Posted by Koen Piller @ 12/29/2011 6:23:57 PM
RE: Set default to in Multiuser Posted by Khurram Tahir @ 12/29/2011 6:44:27 PM
RE: Set default to in Multiuser Posted by Koen Piller @ 12/29/2011 7:13:52 PM
RE: Set default to in Multiuser Posted by Jun Tangunan @ 12/30/2011 4:28:13 AM
RE: Set default to in Multiuser Posted by Pete Sass @ 12/29/2011 6:48:16 PM
RE: Set default to in Multiuser Posted by Khurram Tahir @ 12/29/2011 7:00:52 PM
RE: Set default to in Multiuser Posted by Pete Sass @ 12/29/2011 7:24:54 PM
RE: Set default to in Multiuser Posted by Jun Tangunan @ 12/30/2011 4:15:56 AM
RE: Set default to in Multiuser Posted by Pete Sass @ 12/29/2011 7:47:07 PM
RE: Set default to in Multiuser Posted by Khurram Tahir @ 12/30/2011 4:17:36 AM
RE: Set default to in Multiuser Posted by Gordon King @ 12/30/2011 8:24:36 AM
RE: Set default to in Multiuser Posted by Gordon King @ 12/29/2011 8:47:35 PM
RE: Set default to in Multiuser Posted by Suresh Adhikari @ 12/30/2011 12:46:27 PM