Link to home
Start Free TrialLog in
Avatar of woodwyn
woodwynFlag for United States of America

asked on

How to allow multiple VFP app users to transfer files to a secured shared directory.

How to allow multiple VFP app users to transparently transfer files to a secured shared directory.

I have multiple users connecting to a RDS server hosted on my domain.  There is a VPN between my domain and the users domain.  Once connected to the RDS server, they run their VFP app.  From within the VFP app, they select a file using GetFile().  That works fine.  Once a file is selected I want to automatically transfer the file to a shared directory, locked down to admins only.  Users wont have any access to the share except to upload files to it from within the VFP app.  

Here's a mockup of the credentials provided to me to access the share:
Domain: TheUsersDomains
Username: filestorageuser (given admin rights)
Password: FileStorePassw0rd
Location: \\TheirServer\FileStorage

At first, I replaced TheirServer with their servers IP, but VFP doesn’t seem to like IPs in a path, so I added a record to my workstations and to the RDS servers Hosts files.  Then, on my workstation, I connected to the server in File Explorer, entering in the credentials, and now VFP will upload files to it from my workstation.  However, when I create an executable and send it to the RDS server and try to upload files to the shared directory, I am given an error about …invalid path…

I have found some suggestions of a work around like this (I don't want to create a mapped drive the users can access outside of VFP):
oNet = CreateObject('WScript.Network')    
oNet.MapNetworkDrive('I','\\TheirServer\FileStorage',.T.,'filestorageuser','FileStorePassw0rd')

Or this:
net use DriveLetter: \\TheirServer\FileStorage

There was one suggestion that we install FileZilla on TheirServer, set up a generic account that will not be shared with the users and use FTP to transfer the files from within the VFP app.  I don't recall ever using FTP with VFP myself, but it appears to be a viable solution.

What do you think is the best solution for me here?
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

A solution might be to actually create a mapped drive on the fly ...do your copy and then delete it...
It seems that there is also the idea of hiding a mapped drive but right now i cannot test it.
FTP is also a great solution nonetheless..here is a post on it : https://www.tek-tips.com/faqs.cfm?fid=3234
Avatar of woodwyn

ASKER

I'm trying something like this, but even though I remove the temporary mapped drive I get the following error if I need to temporarily recreate it.

lcDrive='\\ADCH\ISFileStorage\2019\O-100001'
DriveExists = (DRIVETYPE("M:") # 1)

oNet = CreateObject('WScript.Network')    
IF DriveExists
* This is to avoid an error in case the drive did not get deleted last time through
      oNet.RemoveNetworkDrive('M:',.T.)
ENDIF

oNet.MapNetworkDrive('M:',lcDrive,.T.,'isfilestorageuser','19FileStore*')

* With a connection made to the server I can now create folders and upload files within my VFP code

oNet.RemoveNetworkDrive('M:',.T.)
RELEASE oNet



The error I get when hitting this line

oNet.MapNetworkDrive('M:',lcDrive,.T.,'isfilestorageuser','19FileStore*')

the second time through:

OLI IDidpatch exception code 0 from WSHNetwork.MatpNetworkDrive:
The local device name has a remembered connection to another network resource.

If I change the drive letter from M to something else not in use, everything else works again.
Avatar of woodwyn

ASKER

Remembering that I need to display the folder contents, FTP does not solve all my issues.  I still need the user to have temporary access to that server to capture the contents.

Also, here’s another real time example of a possible use to this approach.  I am creating a job folder (\\ADCH\ISFileShare\YearofShow\JobNumber) for each job.  This is where they will dump final, read only versions of docs.  I have a recursive program that I am working on that will display all the contents of the job folder for an easy view within my app.  Here I check to see if the folder exists and if it doesn’t I create it.  This also shows that FTP won’t solve my problem because I need to search for and create these folders on the fly and seamlessly to the user.  

      oNet = CreateObject('WScript.Network')    
      DriveExists = (DRIVETYPE("M:") # 1)
      IF DriveExists
            oNet.RemoveNetworkDrive('M:',.T.)
      ENDIF
     
      lcJobNum=ALLTRIM(oLib.GetWorkorderKeysJobNum(vWorkorders.keyWorkorders))
      lcYear=ALLTRIM(STR(YEAR(vShows.ShowDate)))
      lcFolderPath='\\ADCH\ISFileStorage\'+lcYear+'\'+lcJobNum
      lcDrive='\\ADCH\ISFileStorage\'+lcYear

      oNet.MapNetworkDrive('M:',lcDrive,.T.,'isfilestorageuser','19FileStore*')

      llDir=DIRECTORY(lcFolderPath)
      IF !llDir
            MD (lcFolderPath)
      ENDIF

      DriveExists = (DRIVETYPE("M:") # 1)
      IF DriveExists
            oNet.RemoveNetworkDrive('M:',.T.)
      ENDIF
      RELEASE oNet
ASKER CERTIFIED SOLUTION
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of woodwyn

ASKER

This issue was complicated by the customer informing me that the data host actually resides at an offsite facility, meaning the security issues were outside of my control.  My solution was to create a SQL (their backend)  table that holds requests for files transfers.  Then I created a monitor that resides on a server without security issues to anywhere and the monitor transfers the files.  Thanks again.  I'll close this ticket and disburse points.