Solved

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

Posted on 2003-12-02
3
1,265 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
  • 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 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