Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP 5.0 Middle Tier Cannot Read UNC
Message
De
23/03/1999 13:42:42
Robert Byrd
National Association of Homebuilders
Washington, District de Colombia, États-Unis
 
 
À
23/03/1999 13:30:50
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00199506
Message ID:
00201074
Vues:
14
I am not sure how you meant the comment that asking me to read the documentation may be too much to ask. Unlike many techies, I am sometimes not averse to such diversions. 8^)

>>I have not used your code as is because I do not know how to use it. While I am learning this stuff as fast as I can, I am a project manager with VERY limited resources managing some complex systems. So this link to you is a vital one for me.
>>
>>(By the way, if you know a good VB person in the DC area who might be looking for a job let me know.)
>>
>>The middle tier is one BIG class (out-of-process executable). In order to implement your code do I have to have a separate class or can I set it up as method(s) in the existing class?
>>
>>Indeed, lsDataPath is a NETRESOURCE structure in the form \\server name\share name\subdirectory name as follows: "\\MTX1\LM2\DATA". Since this is a NETSOURCE structure, is it likely that I am barking up the wrong tree looking at WNetAddConnection3 for a solution?
>>
>
>No, you have a UNC - a universal name for the remote resource in a NetBIOS context. A NETRESOURCE structure is a C structure which contains a number of pieces of information, one of which is a pointer to the UNC for the remote resource. The NETRSC.ZIP contains a class which is capable of constructing and maintaining a NETRESOURCE structure, which would then be passed to the API call. DEMO_WNetAddConnection3.PRG is a UDF which implements the WNetAddConnection3 API call, using the NETRESOURCE class contained in NETRSC, and indirectly, via the Heap class contained in CLSHEAP.
>
>I'd look to add the two classes contained in the procedure files, along with the UDF, to the source for your application, and use the one narrow function to do wht needs to be done. If you prefer to roll your own, the details are all spelled out in the MSDN documentation on the WNetAddConnection3 API call and the NETRESOURCE structure. You will need to construct some structures in memory; CLSHEAP provides a mechanism to do this with its Heap class; alternatively, Paul Tatavu's POINTERS class can do the necessary memory allocation. Or you can roll your own. Your choice.
>
>If you read the comments in the code (probably expecting far too much, but I'll ask you to anyway) it shows you exactly how to use the procedure files and UDF.
>
>>
>>
>>
>>
>>>>I now have the following code in the middle tier:
>>>>
>>>>****************************************************************************
>>>>DECLARE INTEGER WNetAddConnection3 IN WIN32API ;
>>>> INTEGER hWND, ;
>>>> STRING @ lpNETRESOURCE, ;
>>>> STRING @ lpPassword, ;
>>>> STRING @ lpUserID, ;
>>>> INTEGER dwFlags
>>>>DECLARE INTEGER GetActiveWindow IN WIN32API
>>>>nResult = WNetAddConnection3(GetActiveWindow(),lsDataPath,'','',0)
>>>>
>>>
>>>Unless lsDataPath is a NETRESOURCE structure, it won't work. I'd construct the necessary structure using the NETRESOURCE class. believe it or not, there is a reason for the class to exist.
>>
>>
>>
>>>
>>>You need to set the Remotename member of the NETRESOURCE structure to point to the share ( the form should be \\server name\share name ) not the specific file you want to look at. If you use the DEMO_WNetAddConnection3 function as it exists in the zip file, simply:
>>
>>Is the "Remotename member" in the position of lsDataPath? I think I am already doing this.
>>
>>
>>
>>>
>>>nResult = DEMO_WNetAddConnection3('','\myserver\myshare')
>>>
>>>should be adequate to force the connection to be made. Forcing the connection in this case means that the server sharing the resource will be logged into, in this case using the current user's Windows Login and password, unless there is a remembered connection string for this system for this user in the user's .PWL file under Win9x. No drive letter is attached, but the user does log into the other machine, which will permit you to access files to whatever extent you have permissions granted.
>>>
>>>The reason that a UNC doesn't automatically let you see what's present within a share is that Windows doesn't let you see beyond the existence of the share (and sometimes it'll even hide that!) until it determines that you have a right to view it. That requires a login to occur, either to the station itself, or to a system that provides authentication for the remote system.
>>>
>>>Is there some reason not to use the sample code as it was provided? If you feel that it's poorly implemented, you can write your own, but if you want to use the API call, it helps to give it data in the format that it expects to receive it.
>>>
>>>>this.writetolog('nresult = ' + ALLTRIM(STR(nResult)))
>>>>*this.writetolog('nresult = ' + nResult)
>>>>
>>>>
>>>> IF ISNULL( .msTempDBC )
>>>> lsUniqueDBC = SYS( 2015 )
>>>> lsCopy = "COPY FILE " + lsData + ".d* TO \\mtx1\c$\temp\" + lsUniqueDBC + ".*"
>>>> &lsCopy
>>>>****************************************************************************
>>>>
>>>>This results in the following error and debug text:
>>>>
>>>>****************************************************************************
>>>>** Debug Text ******************
>>>>WHEN: 03/22/99 05:12:17 PM
>>>>OBJECT: cusbusobj
>>>>TEXT: nresult = 487
>>>>
>>>>** ERROR **********************
>>>>WHEN: 03/22/99 05:12:17 PM
>>>>OBJECT: cusbusobj
>>>>ERROR#: 1
>>>>DESCR: File '\\mtx1\lm2\data\lm2.d*' does not exist.
>>>>METHOD: setprofile
>>>>LINE#: 0
>>>>****************************************************************************
>>>>
>>>>Notice that nresult appears to have a valid value, but the UNC is still not recognized. Is my execution correct?
>>>>
>>>>Bob
>>>>
>>>>
>>>>
>>>>>>All right! It is starting to come together for me. Now, I need to get into the details as to how I can make this work for me.
>>>>>>
>>>>>>Suppose I make a call to WNetAddConnection3 and get a NO_ERROR result. How do I subsequently use the connection created? If the return value is NO_ERROR then the call does not provide me with a connection handle. Does that mean that the UNC is the connection handle?
>>>>>>
>>>>>
>>>>>If you haven't assigned the connection to a mapped drive letter or device, then the UNC is available - you've logged into the machine or its authentication source and been granted at least some set of rights, so that you can now safely use the UNC, knowing that if FILE() returns .F., the file really and truly doesn't exist, rather than no connection to the machine having been established to that point.
>>>>>
>>>>>>It seems that I just need to understand the interface with the resulting connection and, barring other detail snags, I should be able to put this into my existing middle tier code and test it.
>>>>>>
>>>>>>MANY THANKS, Bob
>>>>>>
>>>>>>>>If I am understanding your response correctlyu, my situation is would be the inverse of what you describe. I can access the UNC using Network Neighborhood, but my runtime code says the UNC does not exist.
>>>>>>>>
>>>>>>>
>>>>>>>Visibility of a share doesn't mean that you've been logged in and granted access to the content. Until you actually attach to the machine, and depending on the securuty, been authenticated, visibility means just that - you know it's there.
>>>>>>>
>>>>>>>>I am using the WIN32 API anyway, so another call to won't add any admin overhead. I might be able to figure out how to put in a test to see if it can make a difference.
>>>>>>>>
>>>>>>>>Thanks again.
>>>>>>>>
>>>>>>>>Bob
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>>I really appreciate your help and I KNOW that you are trying to help me. But I am getting way lost.
>>>>>>>>>>
>>>>>>>>>>Let's see if I can understand what is going on with this.
>>>>>>>>>>
>>>>>>>>>>I take it that if I use the WNetAddCOnnection3()that there is a presumption that something called a "connection" is missing and is required. How does this respond to my previous question concerning the fact that I can access the UNC from Network Neighborhood? What is this "connection" that is missing and how could a qualified UNC no longer qualify during runtime? Did a "connection" get dropped?
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>WNetAddConnection3 is an API call that is used to connect to network resources by name. There are any number of reasons that a UNC might not be visible in Network neighborhood; the share might be hidden, or your default peer-to-peer connection might not be using the right protocol to reach the other system. The API call may be able to connect even when you can't see it; there are plenty of times I've been able to connect to a share where i knew the name but it wasn't visible in network Neighborhood.
>>>>>>>>>
>>>>>>>>>Maybe you'd be better off having someone troubleshoot your network for you, so that you're more comfortable with how things appear.
>>>>>>>>>
>>>>>>>>>>I am having a hard time understanding how this is addressing my question.
>>>>>>>>>>
>>>>>>>>>>I apologize if I sound really ignorant, but I am. My knowledge of this topic is apparently very shallow.
>>>>>>>>>>
>>>>>>>>>>Talk to me like I'm stupid and maybe I can get it.
>>>>>>>>>>
>>>>>>>>>>Thanks again, Bob
>>>>>>>>>>
>>>>>>>>>>>>THANKS for the response.
>>>>>>>>>>>>
>>>>>>>>>>>>The UNC that is being accessed (\\MTX1\LM2) maps to the physical machine that is the middle tier. I can go to the console of that machine and open that UNC via Network Neighborhood. I just cannot fathom how there could be no "attachment" at runtime. To me it looks like some sort of hiccup in VFP 5.0.
>>>>>>>>>>>>
>>>>>>>>>>>>I cannot use a drive mapping because I have Crystal Reports called from the front-end that use the datapath as a UNC to get the DBF for the report form. If I were to use a drive mapping such as "C:\LM2", the client would be looking on the workstation's C drive for the DBF instead of on the middle tier's C drive.
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>If you map a drive, you can retrieve the UNC that equates to it. Look back a day or two at the messages - I posted some code for Bruce that made the necessary API call to convert a mapped drive letter to a UNC.
>>>>>>>>>>>
>>>>>>>>>>>>I am not even vaguely familiar with "NETRSC". Maybe you could help me out by pointing me to it.
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>NETRSC.ZIP is available for download here on UT in the FIles Section. It relies on another class that I wrote, CLSHEAP, to permit it to implement and manipulate NETRESOURCE structures, which are used by many of the WNet family of API calls. One of the demo programs in NETRSC is DEMO_WNetAddConnection3(), which uses NETRSC to implement the WNetAddCOnnection3() API call, which can attach a share without mapping a drive.
>>>>>>>>>>>
>>>>>>>>>>>Both CLSHEAP.ZIP and NETRSC.ZIP are available here.
>>>>>>>>>>>
>>>>>>>>>>>>Thanks again,
>>>>>>>>>>>>Bob
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>>>I have an out of process VFP executable that functions a middle tier with a VB 6.0 front-end.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>My app allows the user to choose which middle tier machine to use.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>When I run the app on bbyrd and select bbyrd as the middle tier I get no error. But when I run the app and select MTX1 as the middle tier I get an error in my error log that "\\mtx1\lm2\data\lm2.d*" does not exist.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>The line of code that is executing is trying to copy a DBC set of files. The EXACT same code works fine locally.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>The actual UNC string is being picked up from an INI file.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>What could be causing the remote middle tier to not see the qualified UNC. I have checked the UNC against what the remote middle tier machine can actally see and it should work.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>It's likely that there's no current attachment to the target system at the mid-tier server. You might want to either premap a drive on that system, or take a look at NETRSC (you'll need NETSC.ZIP and CLSHEAP.ZIP) and adapt the sample DEMO_WNetAddConnection3 code to force a connection to the target server without first mapping a drive.
>>>>>>>>>>>>>
>>>>>>>>>>>>>>I think I have really done a VERY thorough job of eliminating most of the obvious suspects. What do you think?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>Call me Loony in Lanham,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>Bob
Database Development Team
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform