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
Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb.Net Loading Word 11 105
Windows Installer 4 76
WPF - External data binding to controls inside a UserControl 2 68
VIDEO DATASOURCE Control Resize issue 2 30
This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…

840 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