Solved

WNetAddConnection2

Posted on 1997-07-15
7
420 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
Comment Utility
Edited text of question
0
 
LVL 3

Expert Comment

by:Ikon
Comment Utility
Did you ask in the programming section?
0
 

Author Comment

by:hemamundkur
Comment Utility
Adjusted points to 100
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:hemamundkur
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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 …
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 …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now