Re: Change NT Service user name and password after installation
From: Sean Hederman (usemy_at_blogentry.com)
Date: 02/26/05
- Next message: Karen: ".net framework V2.0.40903"
- Previous message: Sean Hederman: "Re: Why no serious MS Application in .NET yet ??"
- In reply to: Bruce Parker: "Re: Change NT Service user name and password after installation"
- Next in thread: William DePalo [MVP VC++]: "Re: Change NT Service user name and password after installation"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 26 Feb 2005 23:38:29 +0200
>From the looks of things you'll have to use P/Invoke for this. The
ServiceController doesn't have a Restart method, nor does it provide access
to the user credentials. You could get around the Restart issue by spawning
another process that starts the service (say, "net start myservice") on
service stop.
"Bruce Parker" <bparkerhsd@nospam.nospam> wrote in message
news:904D1E93-64EF-403B-804D-8719EA35470F@microsoft.com...
> The service has to run under a specific account that we specify to the
> customer. There are a lot of reasons for this but would take too long to
> explain. I need a programmatic way to modify the user name and password.
> The service is a .NET service and I want to perform the check in the
> OnStart
> event. If this is not possible, I do want to launch a .NET executable to
> perform this task.
>
> How do I do this programmatically through .NET?
>
> "Sean Hederman" wrote:
>
>> I'd say that your service should launch an external app which will
>> perform
>> the restart. Unfortunately if the user that your service is logged in as
>> doesn't have permission to start and stop services, and change service
>> permissions then this won't work.
>>
>> Is there any particular reason you want to limit the user name? I would
>> be
>> very unhappy if a service told me what user name it wanted. Surely all
>> the
>> service really need is the correct permissions? Also, I'd classify any
>> service which elevated it's own privileges as a serious security risk.
>> Rather just fail on start and write to the event log what you want to
>> happen. Then the system administrator can decide what to do.
>>
>> Also, if you're looking at changing to one of the standard user id's
>> beware
>> about localization issues. Also keep in mind that many network admins
>> remove
>> the standard user names off their systems. One I know has no
>> Administrator
>> accounts on any machine.
>>
>> "Bruce Parker" <bparkerhsd@nospam.nospam> wrote in message
>> news:67E1A786-F70D-4DA3-B5F0-70FCCE72377D@microsoft.com...
>> > Is there a way to change a NT Service's user name and password after it
>> > has
>> > been installed. I want to perform a check for the user name in the
>> > On_Start
>> > event of the service. If it is not the one I want I want to change the
>> > user
>> > name and password and then allow the service to start.
>>
>>
>>
- Next message: Karen: ".net framework V2.0.40903"
- Previous message: Sean Hederman: "Re: Why no serious MS Application in .NET yet ??"
- In reply to: Bruce Parker: "Re: Change NT Service user name and password after installation"
- Next in thread: William DePalo [MVP VC++]: "Re: Change NT Service user name and password after installation"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|