Groups | Blog | Home
all groups > asp.net security > april 2008 >

asp.net security : Programatically Use NetworkService User?


coconet
4/4/2008 1:22:05 PM

Using C# 3.5, I would like to set my Service to use the NetworkService
account on the local computer. But I don't know that users password of
course. What is the smart way to handle that?

Thanks.

Joe Kaplan
4/7/2008 12:12:48 PM
If you install the service with the ServiceProcessInstaller class, you can
set the Account property to use ServiceAccount.NetworkService. That is
probably what you should be doing. If you deploy the service with another
technology besides the .NET "installer" class approach (like a traditional
MSI or something), then you can also do this during the deployment with
those other technologies.

Joe K.
--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
[quoted text, click to view]

Joe Kaplan
4/7/2008 2:43:47 PM
I'm not sure what, if any, options are available for deploying COM+ services
like this as I've never written one. I thought you were talking about a
normal Windows service.

I know there are some installer technologies that will probably take care of
these details, but I don't know if there is any matching thing exposed in
..NET. You may need to find the API that does this and write your own
p/invoke wrapper if deployment via .NET code is required.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
[quoted text, click to view]

coconet
4/7/2008 2:51:01 PM

Thanks, but actually I am installing credentials in a COM+ application
(ServicedComponent) and want to set it that way. What to do?


On Mon, 7 Apr 2008 12:12:48 -0500, "Joe Kaplan"
[quoted text, click to view]
Henning Krause [MVP - Exchange]
4/7/2008 11:01:58 PM
Hello,

you want to programmatically create a COM+ application and set it's identity
to Network Service, do I understand you correct?

The way to go here is the COMAdmin interface, which can be reached via COM
Interop (See the ICOMAdminCatalog interface) and google around.

Once you have created the application, set it's identity to NT
Authority\NetworkService and leave the password empty. That should do the
trick.
Given the application catalog in variable apps and your COM+ application in
variable app, this should work:

app.set_Value("Identity", "NT Authority\NetworkService");
apps.SaveChanges

Kind regards,
Henning Krause

[quoted text, click to view]
coconet
4/9/2008 6:07:47 PM

That's great, exactly what I needed. For some reason creating a new
user account on Vista (x64) is buggy with DirectoryEntry, but this is
what I need.

I also need to set the Image Dump Directory to something and enable
dump on application fault, have you seen a way to do that?

Thanks.


On Mon, 7 Apr 2008 23:01:58 +0200, "Henning Krause [MVP - Exchange]"
[quoted text, click to view]
[snip]
AddThis Social Bookmark Button