Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

WNetAddConnection2

Posted on 1997-07-15
7
Medium Priority
?
437 Views
Last Modified: 2013-12-23
The WnetAddConnection2 function fails in my program giving the error - ERROR_NO_NETWORK.

I have set up the machine as a member of an NT domain.
I am also able to run programs such as telnet, ftp and ping.

Is there some other network initialize function that I need
to call before calling WNetAddConnection2?
0
Comment
Question by:hemamundkur
7 Comments
 

Author Comment

by:hemamundkur
ID: 1547249
Edited text of question
0
 
LVL 3

Expert Comment

by:Ikon
ID: 1547250
Did you ask in the programming section?
0
 

Author Comment

by:hemamundkur
ID: 1547251
Adjusted points to 100
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:hemamundkur
ID: 1547252
Answer to Ikon's clarifications:
Yes. I want to know if there is any C/VC++ network initialize call which I need to make before making the 'WNetConnection2' function call in my program? If not, is there a command line
call like 'net start' or something that I can use?

My program does work when I make 'Client for Microsoft Networks'
my primary network logon.  The error comes when I make 'Windows Logon' as my primary network logon. How ever I want it to work
irrespective of the way the user has logged on.
0
 
LVL 3

Expert Comment

by:vinniew
ID: 1547253
yes.  yes.

I've used WNetAddConnection2 before.  You just need to fill in the resource struct carefully, that's all.

Command Line equivalent:

"net use p: \\myserver\sharedrive"

But, with this you have to have a matching user/password.


0
 

Author Comment

by:hemamundkur
ID: 1547254
Thanks for your reply. The wnetAddConnection2 command does work for me too. But ONLY when I have logged on through the 'Client For microsoft windows' primary logon window.

It does not work when I have NOT logged on through the initial logon dialog box. I am passing the user name and password anyway in the WNetAddConnection2 command. So I don't understand why it
should not work.

Here is my code segment:

NETRESOURCE  netResource;
netResource.dwType = RESOURCETYPE_DISK;
netResource.lpLocalName = "F:";
netResource.lpRemoteName = "\\\\mymachine\\cdrive";
netResource.lpProvider = NULL;
stat = WNetAddConnection2(&netResource,"mypasswd","mylogin",0);

0
 
LVL 4

Accepted Solution

by:
Tomun earned 200 total points
ID: 1547255
Your problem seem to be that you need to log on to an NT Domain.
Under the network properties, the NT Domain settings are under the properties for the Client For Microsoft Networks.
It makes sense that Client For Microsoft Networks should be the
primary logon if you want it to use these settings.

I am on a Win95 only network so I dont need to log on to a domain, and WnetAddConnection2 works perfectly and Im using Windows Logon.

When you use Windows Logon can you still see the network neighborhood correctly ? Does your computer find the browse master ?

A workaround you might want to try is getting TweakUI from microsoft and getting that to log in automatically for you.
You sould still then be able to have you network settings on
Client For Microsoft Networks.

Hope this helps.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We recently endured a series of broadcast storms that caused our ISP to shut us down for brief periods of time. After going through a multitude of tests, we determined that the issue was related to Intel NIC drivers on some new HP desktop computers …
An article on effective troubleshooting
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question