Article View: borland.public.cppbuilder.nativeapi
Article #17545Re: Run Service under a given user
From: Remy Lebeau (TeamB)
Date: Fri, 14 Mar 2003 06:25
Date: Fri, 14 Mar 2003 06:25
35 lines
2587 bytes
2587 bytes
What you ask for would require you to alter the service's configuration. You can't just start the service programmably with a given user account directly. You need to either 1) use the SCM to manually change the account, 2) specify the account programmably via CreateService() if installing the service programmably, or else 3) use the ChangeServiceConfig() function to alter an existing service. Also note that if you are using Borland's TService class, it has a ServiceStartName property that you can set at design-time, which gets applied when the TService is installed (which calls CreateService() internally) Also note that Win2K and XP both have pre-defined accounts specifically designed (albeit more limited than the LocalSystem account) to allow services access to the network, rather than needing to use an actual user account. They are named "NT_AUTHORITY\LocalService" and "NT_AUTHORITY\NetworkService". Also note that as an alternative, the service can manually log in to a user account via LogonUser() and then impersonate the user via ImpersonateLoggedOnUser() in order to gain access to the network without having to alter the service's configuration. Gambit "Simon Macneall" <macneall-at-iinet.net.au> wrote in message news:Xns933E87F54F0B0macnealliinetnetau@207.105.83.65... > Our service application needs to be run under a given > user account (needs access to mapped drives). We can set > this manually, but would really like it to be an automagic > process. Does anyone know how to set the log on as > property of a service through the API (or even a > definative, "It can't be done" would help).
Technical Details
Message-ID:
<3e7173b0$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<Xns933E87F54F0B0macnealliinetnetau@207.105.83.65>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,f5533a726961dde4 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-03-13 22:27:57 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <Xns933E87F54F0B0macnealliinetnetau@207.105.83.65> Subject: Re: Run Service under a given user Date: Thu, 13 Mar 2003 22:25:35 -0800 Lines: 37 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 207.175.226.26 Message-ID: <3e7173b0$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1047622576 207.175.226.26 (13 Mar 2003 22:16:16 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail