ServiceAccount 열거형

정의

서비스의 로그온 형식을 정의하는 서비스 보안 컨텍스트를 지정합니다.

public enum class ServiceAccount
public enum ServiceAccount
type ServiceAccount = 
Public Enum ServiceAccount
상속
ServiceAccount

필드

LocalService 0

로컬 컴퓨터에서 권한이 없는 사용자 역할을 하고 모든 원격 서버에 익명 자격 증명을 제시하는 계정입니다.

LocalSystem 2

서비스 제어 관리자에서 사용되고 로컬 컴퓨터에 대한 확장된 권한을 가지며 네트워크에서 컴퓨터 역할을 하는 계정입니다.

NetworkService 1

광범위한 로컬 권한을 제공하고 모든 원격 서버에 컴퓨터의 자격 증명을 제시하는 계정입니다.

User 3

네트워크에서 특정 사용자가 정의한 계정입니다. Account 인스턴스의 UsernamePassword 속성 값을 둘 다 설정하지 않은 경우 ServiceProcessInstaller 멤버에 대해 User를 지정하면 서비스가 설치될 때 올바른 사용자 이름과 암호를 묻는 메시지가 표시됩니다.

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 ServiceAccount 시스템 계정의 보안 컨텍스트를 사용 하 여 새 프로그램을 설치 하는 열거형입니다.

#using <System.dll>
#using <System.ServiceProcess.dll>
#using <System.Configuration.Install.dll>

using namespace System;
using namespace System::Collections;
using namespace System::Configuration::Install;
using namespace System::ServiceProcess;
using namespace System::ComponentModel;

[RunInstaller(true)]
public ref class MyProjectInstaller : public Installer
{
private:
    ServiceInstaller^ serviceInstaller1;
    ServiceInstaller^ serviceInstaller2;
    ServiceProcessInstaller^ processInstaller;

public:
    MyProjectInstaller()
    {
        // Instantiate installers for process and services.
        processInstaller = gcnew ServiceProcessInstaller;
        serviceInstaller1 = gcnew ServiceInstaller;
        serviceInstaller2 = gcnew ServiceInstaller;

        // The services run under the system account.
        processInstaller->Account = ServiceAccount::LocalSystem;

        // The services are started manually.
        serviceInstaller1->StartType = ServiceStartMode::Manual;
        serviceInstaller2->StartType = ServiceStartMode::Manual;

        // ServiceName must equal those on ServiceBase derived classes.
        serviceInstaller1->ServiceName = "Hello-World Service 1";
        serviceInstaller2->ServiceName = "Hello-World Service 2";

        // Add installers to collection. Order is not important.
        Installers->Add( serviceInstaller1 );
        Installers->Add( serviceInstaller2 );
        Installers->Add( processInstaller );
    }

    static void Main()
    {
        Console::WriteLine("Usage: InstallUtil.exe [<service>.exe]");
    }
};

int main()
{
    MyProjectInstaller::Main();
}
using System;
using System.Collections;
using System.Configuration.Install;
using System.ServiceProcess;
using System.ComponentModel;

[RunInstaller(true)]
public class MyProjectInstaller : Installer
{
    private ServiceInstaller serviceInstaller1;
    private ServiceInstaller serviceInstaller2;
    private ServiceProcessInstaller processInstaller;

    public MyProjectInstaller()
    {
        // Instantiate installers for process and services.
        processInstaller = new ServiceProcessInstaller();
        serviceInstaller1 = new ServiceInstaller();
        serviceInstaller2 = new ServiceInstaller();

        // The services run under the system account.
        processInstaller.Account = ServiceAccount.LocalSystem;

        // The services are started manually.
        serviceInstaller1.StartType = ServiceStartMode.Manual;
        serviceInstaller2.StartType = ServiceStartMode.Manual;

        // ServiceName must equal those on ServiceBase derived classes.
        serviceInstaller1.ServiceName = "Hello-World Service 1";
        serviceInstaller2.ServiceName = "Hello-World Service 2";

        // Add installers to collection. Order is not important.
        Installers.Add(serviceInstaller1);
        Installers.Add(serviceInstaller2);
        Installers.Add(processInstaller);
    }

    public static void Main()
    {
        Console.WriteLine("Usage: InstallUtil.exe [<service>.exe]");
    }
}
Imports System.Collections
Imports System.Configuration.Install
Imports System.ServiceProcess
Imports System.ComponentModel

<RunInstallerAttribute(True)> _
Public Class MyProjectInstaller
    Inherits Installer
    Private serviceInstaller1 As ServiceInstaller
    Private serviceInstaller2 As ServiceInstaller
    Private processInstaller As ServiceProcessInstaller    
    
    Public Sub New()
        ' Instantiate installers for process and services.
        processInstaller = New ServiceProcessInstaller()
        serviceInstaller1 = New ServiceInstaller()
        serviceInstaller2 = New ServiceInstaller()
        
        ' The services will run under the system account.
        processInstaller.Account = ServiceAccount.LocalSystem
        
        ' The services will be started manually.
        serviceInstaller1.StartType = ServiceStartMode.Manual
        serviceInstaller2.StartType = ServiceStartMode.Manual
        
        ' ServiceName must equal those on ServiceBase derived classes.            
        serviceInstaller1.ServiceName = "Hello-World Service 1"
        serviceInstaller2.ServiceName = "Hello-World Service 2"
        
        ' Add installers to collection. Order is not important.
        Installers.Add(serviceInstaller1)
        Installers.Add(serviceInstaller2)
        Installers.Add(processInstaller)
    End Sub

    Public Shared Sub Main()
        Console.WriteLine("Usage: InstallUtil.exe [<service>.exe]")
    End Sub
End Class

설명

사용 하 여 합니다 ServiceAccount 초기화할 때 열거형을 ServiceProcessInstaller 설치 하는 서비스의 보안 컨텍스트를 지정 하 합니다. 보안 컨텍스트는 서비스는 시스템 및 서비스 (예를 들어 있는지 여부를 표시 컴퓨터의 자격 증명 또는 원격 서버에 익명 자격 증명) 네트워크에서 작동 하는 방법에 권한을 나타냅니다. ServiceAccount 열거형에서는 특정 서비스에 필요한 권한을 정확 하 게 지정할 수 있는 권한 범위를 제공 합니다.

LocalSystem 값은 높은 권한이 필요한 계정을 정의 하지만 대부분의 서비스와 같은 상승 된 권한 수준이 필요 하지 않습니다. 합니다 LocalServiceNetworkService 열거형 멤버 보안 컨텍스트에 대 한 보다 낮은 수준의 권한을 제공 합니다.

참고

LocalServiceNetworkService Windows XP 및 Windows Server 2003 제품군 에서만 사용할 수 있습니다.

적용 대상

추가 정보