site then that path will map automatically. If the user doesnt have any rights
the i need to get the username and pwd from the user by using windows authentication screen. For example the
WNetConnectionDialog shows the mapnetwork drive dialogbox.For example if you open an IE explorer and type the servername which you dont have access
In the mean while I found WNetAddConnection Function can be used to map that drive.
Here is the code I am using.But I am facing one problem
Expand|Select|Wrap|Line Numbers
- Option Explicit
- Private m_WindowsUserName As String
- Private m_NetworkPath As String
- Private ErrInfo As Long
- 'Initialization of Varraibles
- 'Private Sub Class_Initialize()
- ' MapDrive
- 'End Sub
- Private Function MapDrive()
- Dim NetR As NETRESOURCE
- Dim MyPass As String, MyUser As String
- NetR.dwScope = RESOURCE_GLOBALNET
- NetR.dwType = RESOURCETYPE_DISK
- NetR.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE
- NetR.dwUsage = RESOURCEUSAGE_CONNECTABLE
- NetR.lpLocalName = "X:" ' If undefined, Connect with no device
- NetR.lpRemoteName = m_NetworkPath ' Your valid share
- ' If the MyPass and MyUser arguments are null (use vbNullString), the
- ' user context for the process provides the default user name.
- ErrInfo = WNetAddConnection2(NetR, MyPass, MyUser, _
- CONNECT_INTERACTIVE Or CONNECT_PROMPT)
- 'CONNECT_INTERACTIVE )
- If ErrInfo = NO_ERROR Then
- MsgBox "Net Connection Successful!", vbExclamation, "Share Connected"
- Else
- MsgBox GetErrorInfo, vbExclamation, "Share Not Connected"
- End If
- End Function
- 'Function get the Error description using Error Id
- Private Function GetErrorInfo() As String
- If ErrInfo = NO_ERROR Then
- 'If no Error do nothing
- ElseIf ErrInfo = ERROR_CANCELLED Then
- GetErrorInfo = "User Cancelled !"
- ElseIf ErrInfo = ERROR_NO_NET_OR_BAD_PATH Then
- GetErrorInfo = "Network Not Found !"
- ElseIf ErrInfo = ERROR_NO_NETWORK Then
- GetErrorInfo = "Network Not Found !"
- ElseIf ErrInfo = ERROR_DEVICE_ALREADY_REMEMBERED Then
- GetErrorInfo = "The Network is Already Connect. Please disconnect it and try again !"
- Else
- GetErrorInfo = ErrInfo & " - Net Connection Failed!"
- End If
- If Len(GetErrorInfo) > 0 Then
- GetErrorInfo = "ERROR : " & GetErrorInfo
- End If
- End Function
- Public Property Get NetWorkPath() As String
- NetWorkPath = m_NetworkPath
- End Property
- Public Property Let NetWorkPath(ByVal vNewValue As String)
- m_NetworkPath = vNewValue
- End Property
- Public Function MapRemoteDrive()
- MapDrive
- End Function
authentication window.Can some one Help
Thanks in advance
Dana