Problem Mapping a NetworkDrive

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mirko Parisi

    Problem Mapping a NetworkDrive

    Hi all!
    I have a procedure to Map a Network Drive on Shared Folder from a server
    in my intranet (this heppens after the user has put Username and
    Password in a form used for Domain Authentication)

    The code is already functioning in VB6 but i would like to apply it also
    in a Acc97 application. Unfortunately the Api call doesn't work.

    Here's the code

    ------------------------------------

    -------------
    DECLARATIONS
    -------------

    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

    Private Declare Function WNetAddConnecti on2 Lib "mpr" _
    Alias "WNetAddConnect ion2A" _
    (lpNetResource As NETRESOURCE, _
    ByVal lpPassword As String, _
    ByVal lpUserName As String, _
    ByVal dwFlags As Long) As Long


    Private Const ERROR_SUCCESS = 0
    Private Const CONNECT_UPDATE_ PROFILE = &H1
    Private Const RESOURCETYPE_DI SK = &H1
    Private Const RESOURCETYPE_PR INT = &H2
    Private Const RESOURCETYPE_AN Y = &H0
    Private Const RESOURCE_GLOBAL NET = &H2
    Private Const RESOURCEDISPLAY TYPE_SHARE = &H3
    Private Const RESOURCEUSAGE_C ONNECTABLE = &H1

    Dim NETR As NETRESOURCE

    Dim errInfo As Long
    Dim result As Boolean

    Dim strRemoteDrv as string
    Dim strNetDrive

    ---------
    PROCEDURE
    ---------

    ....
    ......
    strNetDrive = "q:"
    strRemoteDrv = "\\svnt01\orehr "

    With NETR
    .dwScope = RESOURCE_GLOBAL NET
    .dwType = RESOURCETYPE_DI SK
    .dwDisplayType = RESOURCEDISPLAY TYPE_SHARE
    .dwUsage = RESOURCEUSAGE_C ONNECTABLE
    .lpRemoteName = strRemoteDrv
    .lpLocalName = strNetDrive
    End With

    errInfo = WNetAddConnecti on2(NETR, LCase(Me.txtPas sword),
    LCase(Me.txtUse rName), CONNECT_UPDATE_ PROFILE)

    result = errInfo = ERROR_SUCCESS

    If Not result Then
    MsgBox "Impossibil e mappare l'unità di rete del BackEnd. Impossibile
    continuare.", vbCritical + vbOKOnly, "LeOreHR"
    DoCmd.Quit
    End If
    -------------------------------------

    Me.txtUserName e Me.txtPassword are supplied in a form and are the same
    used for the domain's login.
    The procedure is executed only if the Q: drive in not mapped (if its
    mapped to a different share the app stops and close automatically).

    I can't understand where the problem is and why the same code is ok for
    VB6 and not for VBA.

    Thanks to anyone who'll give me some help
    bye
    Mirx

    PS: sorry for my bad english


    --
    Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Working...