Solved

wnetaddconnection fails ?

Posted on 2003-11-05
3
313 Views
Last Modified: 2012-06-27
hi,
   i am writing a small code to have remote shutdown of winNT/2k servers.
hence i first tried to write using Wnetaddconnection to get connected using admin/password , since directly using initiatesystemshutdown API doestn allow me to get priviliege to shutdown.(i dont know why)
i tried to give the privilage using lookupprivilage,accesstoken api's but failed.
  my now probs is Wnetaddconnection fails and gives error values as 67(i cant trace what it is using wnetgetlasterror). may be  NETRESOURCE.lpszRemotename is wrong.
so can u provide some sample code to do such a thing
kiran
0
Comment
Question by:kirannapit
3 Comments
 
LVL 3

Accepted Solution

by:
Madz earned 76 total points
ID: 9693344
Try using NetUseAdd to add a connection to a remote resource.

USE_INFO_2 ui2;

ZeroMemory(&ui2, sizeof(ui2));

ui2.ui2_local = NULL;
ui2.ui2_remote = szRemoteResource; // Your remote resource path. In your case it could be \\<server>\IPC$
ui2.ui2_asg_type = USE_IPC;
ui2.ui2_password = ui2.ui2_username = ui2.ui2_domainname = L"";

nas = NetUseAdd(NULL, 2, (LPBYTE)&ui2, NULL);

Madz
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10242565
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: Madz {http:#9693344}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

863 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

23 Experts available now in Live!

Get 1:1 Help Now