Solved

WNetAddConnection2

Posted on 1997-07-15
7
423 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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 100 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AD health monitoring 2 75
Choppy program performance on Windows Server 2012 20 89
Windows Security Event ID to check for Service account usage 3 153
Folder Replication 4 63
Enterprise networks where VoIP phones have been deployed frequently use port configurations that allow both a computer and an IP phone to be plugged into the same switch port but use different VLANs. On Cisco equipment I'm referring to the "native V…
A common practice in small networks is making file sharing easy which works extremely well when intra-network security is not an issue. In essence, everyone, that is "Everyone", is given access to all of the shared files - often the entire C: drive …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

808 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