|
-
Jun 15th, 2000, 11:14 PM
#1
Thread Starter
New Member
I am having some trouble with getting WNetAddConnection2 API call in vb6 to work with any UserID other than a user that is in the Administrator Group. The error code that is returned by the system is always 1208. Here is the Code I'm using:
========================================================
Public 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
Public Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" _
(ByVal lpName As String, _
ByVal dwFlags As Long, _
ByVal fForce As Long) _
As Long
Public Const ERROR_NOT_CONNECTED = 2250&
Public Const ERROR_EXTENDED_ERROR = 1208&
Public Const ERROR_MORE_DATA = 234
Public Const ERROR_ACCESS_DENIED = 5&
Public Const ERROR_ALREADY_ASSIGNED = 85&
Public Const ERROR_BAD_NET_NAME = 67&
Public Const ERROR_BAD_DEV_TYPE = 66&
Public Const ERROR_BUSY = 170&
Public Const ERROR_CANNOT_OPEN_PROFILE = 1205&
Public Const ERROR_DEVICE_ALREADY_REMEMBERED = 1202&
Public Const ERROR_INVALID_PASSWORD = 86&
Public Const ERROR_NO_NET_OR_BAD_PATH = 1203&
Public Const ERROR_NO_NETWORK = 1222&
Public Const RESOURCETYPE_ANY = &H0
Public Const RESOURCETYPE_DISK = &H1
Public Const RESOURCETYPE_PRINT = &H2
Public Const CONNECT_UPDATE_PROFILE = &H0
Public 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
Dim lRes&, sRes$, sPass$, sUser$
Dim udtNet As NETRESOURCE
_______________________________
Sub ConnectDrive()
With udtNet
.dwType = RESOURCETYPE_DISK
.lpLocalName = "W:" & Chr(0)
.lpRemoteName = "\\ServerName\HiddenShareName$" & Chr(0)
End With
sUser = "NonAdministrativeUser" & Chr(0)
sPass = "password" & Chr(0)
lRes = WNetAddConnection2(udtNet, ByVal sPass, ByVal sUser, CONNECT_UPDATE_PROFILE)
End Sub
____________________________________
Sub DisconnectDrive()
lRes = WNetCancelConnection2("W:", CONNECT_UPDATE_PROFILE, False)
End Sub
==========================================================
Can anyone offer some insight into either solving the problem or finding out how to get the Extended Error Information?
Thanks in Advance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|