Solved

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

Posted on 2003-12-02
3
1,259 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
Comment Utility
>>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
Comment Utility
BTW, you can also use

LPCTSTR pszAcctName = "MachineName\\UserName";

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

Author Comment

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

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).

Join & Write a Comment

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…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

728 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

14 Experts available now in Live!

Get 1:1 Help Now