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:
Private Type NETRESOURCE
dwScope As Long
dwType As Long
dwDisplayType As Long
dwUsage As Long
lpLocalName As String
lpRemoteName As String
lpComment As String
lpProvider As String
End Type
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
Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" (Byval lpName As String, Byval dwFlags As Long, Byval fForce As Long) As Long
Private Const RESOURCETYPE_DISK = &H1
Problematic Code
vb Code:
Dim nr As NETRESOURCE, l As Long
nr.dwType = RESOURCETYPE_DISK
nr.lpLocalName = ""
nr.lpRemoteName = "\\*removed URL*\BreakoutRoomBooking"
nr.lpProvider = ""
l = WNetAddConnection2(nr, "Domain Admin Account here", "admin password here", 0)
If l = 0 Then
Msgbox "Connection Established"
Else
Msgbox "Connection Failed."
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