WNetAddConnection2 Fails Across Untrusted Domains

S

Scott Kay

I would please like some help solving an annoying problem with the use Win32
API WNetAddConnection2 from VB.Net 2003, a Windows XP client, and Windows
2003 Web Server server.

The client is on domain A and the server and user account is on domain B.
Domain A does not trust domain B and vice versa. I am trying to establish a
connection to a drive share on domain B using a user account on domain B
from a client on domain A. The user on domain B has proper permission to
view the share on domain B. I recieve error 1326/Logon failure: unknown
user name or bad password. The user is correct and the password is correct.

I have been able to eliminate the possbility of a bad API call because the
function works if the client is also on domain B. I have also been able to
eliminate network problems with the client on domain B because I have been
able to make the desired connection using Windows Explorer and providing the
user name from domain B.

Here is my source code. Again, any help would be greatly appreciated. As a
reminder, the client is on Domain A, the server and user account are on
Domain B.
Const RESOURCETYPE_DISK = &H1
Const RESOURCE_GLOBALNET = &H2&
Dim theNetResource As NETRESOURCE
Dim strUsername As String
Dim strPassword As String
Dim result As Integer
theNetResource = New NETRESOURCE
theNetResource.lpProvider = Nothing
theNetResource.dwDisplayType = 3 'RESOURCEDISPLAYTYPE_SHARE
theNetResource.dwUsage = 1 'RESOURCEUSAGE_CONNECTABLE
theNetResource.dwScope = RESOURCE_GLOBALNET
theNetResource.lpRemoteName = \\server 'on domain B
theNetResource.lpLocalName = "" 'No local mapping desired. Just
connection.
strUsername = "domainB\username"
strPassword = "password"
theNetResource.dwType = RESOURCETYPE_DISK
result = WNetAddConnection2(theNetResource, strUsername, strPassword, 0)

This does not work and I am not sure why. Googling hasn't helped so far.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top