473,394 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

WNetAddConnection2 Fails Across Untrusted Domains

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.
Jul 21 '05 #1
1 7952
nbb
1
Try switching position of strUsername and strPassword.

Instead of

result = WNetAddConnection2(theNetResource, strUsername, strPassword, 0)

try

result = WNetAddConnection2(theNetResource, strPassword, strUsername, 0)

This is because the API declaration is as follows:

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
Feb 16 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: d.schulz81 | last post by:
Hi all, We have about 10 different domains that are linked very closely and we want to identify and keep track of every single user that surfs our websites by the use of sessions. The problem...
2
by: Keon | last post by:
Hoi Is it possible to use cookies between different domains? For my site I use 2 domains; the first for my global site with ASP en HTML the second is for my forum located on "hyperboards" a...
2
by: googleboy | last post by:
I have created a html-page with formelements that via a javascript get their data from an iframe that calls a external XLM-page. The solution works in MS Explorer, but only if the browser security...
7
by: Doug | last post by:
An ASP.NET session cookie set on "www.mydomain.com" can not be accessed on "search.mydomain.com"; hence, a new session and cookie are being created on every sub-domain. This is occuring because...
0
by: Scott Kay | last post by:
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...
3
by: BBM | last post by:
Hi everyone, This is probably a truly stupid question, but here goes. I'm trying to use the VB version of an application framework. I'm sure it works. I've been using the C# version for...
1
by: ozgur uksal | last post by:
hi, Is there any way to upload data across domains? In other words, assume you own two domains on the same server, and the first domain, that your client visits to upload data, is going to be...
2
by: John M. Gamble | last post by:
I'm getting this message in Visual Studio 2005: PInvokeStackImbalance was detected Message: A call to PInvoke function 'Refresh!Refresh.Main::WNetAddConnection2' has unbalanced the stack. ...
13
by: Samir Chouaieb | last post by:
Hello, I am trying to find a solution to a login mechanism for different domains on different servers with PHP5. I have one main domain with the user data and several other domains that need...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.