Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 362
  • Last Modified:

Access dbf file on remote machine requiring authentication

I am trying to access a .dbf file on a remote Win2K machine using ADO.
I am able to access the file and retrieve the recordset if I create a connection to the remote machine (outside of VB) prior to running the program.  However, I would like to authenticate to the remote machine dynamically, within the VB program.  Passing the login info via UID and PWD in the connection string doesn't seem to work.  Any ideas?

Ken
0
gr8white
Asked:
gr8white
  • 7
  • 3
  • 2
  • +2
1 Solution
 
winner21Commented:
Can I see your code for the database connection string?
0
 
gr8whiteAuthor Commented:
This is the connection string that works as long as the connection has already been established (e.g., mapped network drive):

oConn.Open "Driver={Microsoft dBASE Driver (*.dbf)};" & _
           "DriverID=277;" & _
           "Dbq=\\blngwawd005\c$\cms-r\cmsdata;"

oConn.Open "Driver={Microsoft dBASE Driver (*.dbf)};" & _
           "DriverID=277;" & _
           "Dbq=\\blngwawd005\c$\cms-r\cmsdata;" & _
           "Uid=administrator; Pwd=password"

(where "password" is the actual administrator password).
0
 
gr8whiteAuthor Commented:
What I meant to say in the previous post is that the first string successfully connects as long as I have already authenticated to the remote machine.  If not, it fails.

The second string was my attempt to include the authentication info as part of the connection string, but this fails also if I have not already authenticated.

Ken
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
winner21Commented:
I think there is something wrong with your connection setting, try to use the following one if you want to open a dbf file:

oConn.Open "Provider=vfpoledb;" & _
           "Data Source=C:\vfp7\Samples\Data\myVFPDB.dbf;" & _
           "Mode=ReadWrite|Share Deny None;" & _
           "Collating Sequence=MACHINE;" & _
           "Password=''"

NOTES: vfpoledb is the default provider in MS Windows. don't change it. The only thing you need to do is to add your password and user id.
0
 
gr8whiteAuthor Commented:
The string I am using works when I use it to open a local .dbf file, or one that is on a machine to which I've already established a connection.  The issue is authenticating to the remote machine when I haven't already done so.

The string you provided doesn't work for me because I don't have the "vfpoledb" provider installed.

Ken
0
 
winner21Commented:
The Visual FoxPro OLE DB Provider is NOT installed by MDAC 2.x.  You must install Visual FoxPro 7.0 in order to get it's OLE DB Provider.

so what is the user id and password in your first post, that must be for the server, plus your dbf userid and password.  
0
 
DabasCommented:
I have the feeling that there are two security issues here.

First is logging onto the server
Second is logging onto the database.

My feeling is that your connection string solves the second problem, but not the first.

I would suggest you check the security and access settings on the server.

0
 
gr8whiteAuthor Commented:
You are exactly right, that is exactly what I am asking.  How do I authenticate to the remote machine?  The UID and PWD parameters in the Connect string are for database access only, not OS access.

As I tried to make clear, if I authenticate to the remote machine outside of VB, e.g., by mapping a drive (and being prompted for the login info), everything works fine.  My question, and I think if I ask it correctly there may be a fairly simple answer, is how do I supply the OS login info from VB (without shelling to NET USE or some kludge like that), either as part of the connect string or otherwise?

Ken
0
 
gr8whiteAuthor Commented:
You are exactly right, that is exactly what I am asking.  How do I authenticate to the remote machine?  The UID and PWD parameters in the Connect string are for database access only, not OS access.

As I tried to make clear, if I authenticate to the remote machine outside of VB, e.g., by mapping a drive (and being prompted for the login info), everything works fine.  My question, and I think if I ask it correctly there may be a fairly simple answer, is how do I supply the OS login info from VB (without shelling to NET USE or some kludge like that), either as part of the connect string or otherwise?

Ken
0
 
DabasCommented:
GRRR.. I remember having a similar problem, and trying out so many different solutions, that now I do not remember which one worked!!!

But then, lets think about it a little.
If what you want to do were possible, then there would be a major security breach. It would mean that anybody that runs your program would have access to your server, as you would be setting up the connection and giving a back door entry to its security.

This is where client server comes in.

A client requests information from the server, the server returns the information. This is how your browser is able to give you - say - your bank account details.

The browser, as the client, does not have login access to the bank's computer (At least I hope not if it is my bank!!!!)

The server, does have access (it is logged in properly already!), and supplies the client with an HTML file that has the information.

The client never accessed the data. The server did.
The server already is logged in!

Hope this helps to clarify the issue????

Dabas
0
 
gr8whiteAuthor Commented:
Certainly I understand there are security issues involved when you include authentication information in a program.  As you said, "anyone" who has access to the program has whatever privilege is associated with that login.  So if you do have to use such a program, you need to make sure access to the program is restricted.

What I'm trying to find out is if it is technically possible to do what I am trying to do.  Namely, within the VB program, to authenticate to the remote computer ("log in") so that I can access a file located on that computer using a unc path.  Ideally, this connection would be broken as soon as I have extracted the data I want from the file.

Ken
0
 
CleanupPingCommented:
gr8white:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
gr8whiteAuthor Commented:
I did some research and was able to answer my own question.  The answer involved some API functions in MPR.DLL, WNetAddConnection2 and WNetCancelConnection2, along with a VB wrapper I found.
0
 
YensidModCommented:
Question is PAQ'd and points refunded.

YensidMod
EE Moderator
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now