473,749 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WNetAddConnecti on2 Fails Across Untrusted Domains

I would please like some help solving an annoying problem with the use Win32
API WNetAddConnecti on2 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_DI SK = &H1
Const RESOURCE_GLOBAL NET = &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 'RESOURCEDISPLA YTYPE_SHARE
theNetResource. dwUsage = 1 'RESOURCEUSAGE_ CONNECTABLE
theNetResource. dwScope = RESOURCE_GLOBAL NET
theNetResource. lpRemoteName = \\server 'on domain B
theNetResource. lpLocalName = "" 'No local mapping desired. Just
connection.
strUsername = "domainB\userna me"
strPassword = "password"
theNetResource. dwType = RESOURCETYPE_DI SK
result = WNetAddConnecti on2(theNetResou rce, strUsername, strPassword, 0)

This does not work and I am not sure why. Googling hasn't helped so far.
Jul 21 '05 #1
1 7995
nbb
1 New Member
Try switching position of strUsername and strPassword.

Instead of

result = WNetAddConnecti on2(theNetResou rce, strUsername, strPassword, 0)

try

result = WNetAddConnecti on2(theNetResou rce, strPassword, strUsername, 0)

This is because the API declaration is as follows:

Declare Function WNetAddConnecti on2 Lib "mpr.dll" Alias _
"WNetAddConnect ion2A" (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
4472
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 is how to keep track of the session ID across domains. - cookies don't work because not acepted by 40 % of or users and cookies don't work across domains
2
1879
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 free forum domain On de second domain i don't have any control and i can't put any new webpages on that site.
2
742
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 is changed to allow data access across domains. Has anybody found a way, so the browser default-settings does not need to be changed. Thanx Steve
7
7776
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 ASP.NET always sets the Session cookie domain to the full domain (e.g. "www.mydomain.com") instead of the parent domain (e.g. "mydomain.com") The problem with this is when the visitor goes to a different sub-domain (e.g. "search.mydomain.com"),...
0
355
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 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...
3
1074
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 about 2 years. The errors that I get when I compile are as if inheritance has stopped working or as if I didn't have a valid reference to the System namespace. For example a simple framework method that uses the "equals" method fails
1
1844
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 out of web space, and you want to use the other domain to store data. Since, your php upload script is on the first domain, is there any way to make your php code to upload data to the second domain that contains enough web space (across domains)? ...
2
2662
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. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
13
8672
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 a login to show data. I want the user to login only once when he visits any of my domains.
0
8997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8833
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9568
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9389
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8257
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4709
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3320
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2218
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.