Re: How to remote start/stop services using windows API?



Hi Jeffrey,

Thanks for your reply:)

Logonuser seems only works only when local machine and remote machine have
same usename/password pair. If my application running on machine A under user
"aaaa", the service running on machine B, it must be stopped using user
"bbbb", and this user doesn't exist on machine A. How could I use Logonuser
to stop the service in machine B?

BTW, is there any limitations if machine A is in a domain and machine B is
NOT in domain, and vice versa?

Thanks,
--
Tom Lee


""Jeffrey Tan[MSFT]"" wrote:

Hi Tom,

Thanks for your feedback.

Do you mean that the account you are calling OpenSCManager does not have
enough right to connect remote SCM? So you use the username/password pair
of valid account on remote machine to call WNetAddConnetion2. I assume so.

NetUseAdd and WNetAddConnection2 will both call into the client redirector
for SMB file server connections for windows file server connections, so you
can run into the session conflict with existing connections. Moreover,
there can be any number of legitimate reasons for connections to already
exist to the target server.

The recommended solution is using LogonUser(LOGON32_LOGON_NEW_CREDENTIALS),
impersonate the resultant token, then perform the remote operations. This
will ensure you'll use the specified credentials for remote authenticated
operations, regardless of the transport. So it helps you to avoid the
session re-use issue.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


.



Relevant Pages

  • Re: How to remote start/stop services using windows API?
    ... of valid account on remote machine to call WNetAddConnetion2. ... for SMB file server connections for windows file server connections, ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vc.mfc)
  • Re: How to remote start/stop services using windows API?
    ... of valid account on remote machine to call WNetAddConnetion2. ... for SMB file server connections for windows file server connections, ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.platformsdk.security)
  • RE: How to save file to a shared foled in asp.net
    ... As for the "saving file to remote share" issue, I think it is a typical ... Microsoft MSDN Online Support Lead ... nature are best handled working with a dedicated Microsoft Support Engineer ... In ASP.NET, how to save a file in a shared folder in the server side, the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: SBS Turn-Key Operation
    ... My entire business is primarly mobile, with the chance that an SMB needs ... > then use XP Remote Desktop support a lot easier. ... >> my customers are residental w/ a few SMB accounts. ...
    (microsoft.public.windows.server.sbs)
  • RE: Permissions for remote debugging in Visual Studio 2005
    ... I think you need to add the user in the remote machine's Power User and ... Debugger User group. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet.security)