Results 1 to 1 of 1

Thread: Accessing a network share

  1. #1

    Thread Starter
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Accessing a network share

    Right now we have a program that writes a text file from our NAB and populates it with a bunch of users. Every time the file is updated, we need to copy it to another server so the Room Booking program can use the file for some stuff.

    So I've decided I am going to make it write it automatically to the proper server. Since they are both behind the same firewall, I assumed this would be easy.

    I attempted to just map the drive and write the file, but it has permissions issues and I need to use the Admin username and password.

    I found something that seems that it will work for me, but I am having issues.


    Declarations
    vb Code:
    1. Private Type NETRESOURCE
    2.     dwScope As Long
    3.     dwType As Long
    4.     dwDisplayType As Long
    5.     dwUsage As Long
    6.     lpLocalName As String
    7.     lpRemoteName As String
    8.     lpComment As String
    9.     lpProvider As String
    10. End Type
    11. Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" (lpNetResource As NETRESOURCE, Byval lpPassword As String, Byval lpUserName As String, Byval dwFlags As Long) As Long
    12. Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" (Byval lpName As String, Byval dwFlags As Long, Byval fForce As Long) As Long
    13. Private Const RESOURCETYPE_DISK = &H1

    Problematic Code
    vb Code:
    1. Dim nr As NETRESOURCE, l As Long
    2.     nr.dwType = RESOURCETYPE_DISK
    3.     nr.lpLocalName = ""
    4.     nr.lpRemoteName = "\\*removed URL*\BreakoutRoomBooking"
    5.     nr.lpProvider = ""
    6.    
    7.     l = WNetAddConnection2(nr, "Domain Admin Account here", "admin password here", 0)
    8.    
    9.     If l = 0 Then
    10.         Msgbox "Connection Established"
    11.     Else
    12.         Msgbox "Connection Failed."
    13.     End If



    Basically, the issue is that it keeps saying connection failed, and then the write I attempt just below this fails. I'm just wondering if anyone more familiar with this could possibly point out where I am going wrong/any other possibilities.

    FYI this code is a little different than VB as it is lotusscript, but they are basically the same thing.

    Also, I am 100% positive that the username and password are correct, and that the remote name does indeed point to the proper folder.

    Whether it is supposed to point there or to a different location, I am not sure.

    Any help would be appreciated.


    Thanks,

    Smitty
    Last edited by kfcSmitty; Mar 18th, 2010 at 11:33 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width