Solved

CreateService (Platform SDK): Creating a service with a specific account

Posted on 2003-12-02
3
1,271 Views
Last Modified: 2013-12-03
Hello,

I use the CreateService function of the Platform SDK to create a service that runs under a specific account.

If the user belongs to a domain, I have no problem: In the lpServiceStartName, I use the account name in the form "DomainName\UserName".

But what to do if the user does not belong to a domain, but to a workgroup? I tried "WorkgroupName\UserName" and ".\UserName" for the lpServiceStartName Parameter, but I get error 997 (Overlapped I/O operation is in progress) after the call to CreateService.
I also tried "\UserName", and the CreateService returned no error. But then the OpenService function failed. I got error 1068 (The dependency service or group failed to start). The Logon Service told me in the event log, that the user does not belong to a domain, but to a workgroup.

What's wrong?

I am using MS VC++ 6 and Win 2000.

Thanks,
Markus
0
Comment
Question by:mskohut
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 9858938
>>But what to do if the user does not belong to a domain, but to a workgroup?

It has to be of the form

LPCTSTR pszAcctName = ".\\UserName";

>>But then the OpenService function failed.

You have to ensure that the account you are using is granted the SE_SERVICE_LOGON privilege.
0
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 9858953
BTW, you can also use

LPCTSTR pszAcctName = "MachineName\\UserName";

Workgroups are not not being accounted for in that scheme.
0
 

Author Comment

by:mskohut
ID: 9883016
"MachineName\UserName" worked, ".\UserName" not.

Reason:
Before I call CreateService with the account name, I ensure that the account is granted the SE_SERVICE_LOGON privilege.
In doing this, I call LookupAccountName with the account name (lpAccountName). But this function seems only accept account names in the form "DomainName\UserName" or "MachineName\UserName", NOT ".\UserName".
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

623 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