ServiceAccount ServiceAccount ServiceAccount ServiceAccount Enum

Definição

Especifica o contexto de segurança do serviço, que define o tipo de logon.Specifies a service's security context, which defines its logon type.

public enum class ServiceAccount
public enum ServiceAccount
type ServiceAccount = 
Public Enum ServiceAccount
Herança
ServiceAccountServiceAccountServiceAccountServiceAccount

Campos

LocalService LocalService LocalService LocalService 0

Uma conta que atua como um usuário não privilegiado no computador local e apresenta credenciais anônimas a qualquer servidor remoto.An account that acts as a non-privileged user on the local computer, and presents anonymous credentials to any remote server.

LocalSystem LocalSystem LocalSystem LocalSystem 2

Uma conta, usada pelo gerenciador de controle de serviço, que tem privilégios extensos no computador local e funciona como o computador na rede.An account, used by the service control manager, that has extensive privileges on the local computer and acts as the computer on the network.

NetworkService NetworkService NetworkService NetworkService 1

Uma conta que fornece privilégios locais abrangentes e apresenta as credenciais do computador para qualquer servidor remoto.An account that provides extensive local privileges, and presents the computer's credentials to any remote server.

User User User User 3

Uma conta definida por um usuário específico na rede.An account defined by a specific user on the network. Especificando User para o membro Account faz com que o sistema solicite um nome de usuário válido e uma senha quando o serviço é instalado, a menos que você defina valores para ambas as propriedades Username e Password de sua ServiceProcessInstaller instância.Specifying User for the Account member causes the system to prompt for a valid user name and password when the service is installed, unless you set values for both the Username and Password properties of your ServiceProcessInstaller instance.

Exemplos

O exemplo de código a seguir demonstra como usar o ServiceAccount enumeração para instalar novos programas usando o contexto de segurança da conta do sistema.The following code example demonstrates how to use the ServiceAccount enumeration to install new programs by using the system account's security context.

#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
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

Comentários

Use o ServiceAccount enumeração quando você inicializa um ServiceProcessInstaller para especificar o contexto de segurança do serviço que você está instalando.Use the ServiceAccount enumeration when you initialize a ServiceProcessInstaller to specify the security context of the service you are installing. O contexto de segurança indica os privilégios de que um serviço tem no sistema e como os serviços de agir na rede (por exemplo, se o serviço apresenta credenciais anônimas aos servidores remotos ou para credenciais do computador).The security context indicates the privileges a service has on the system and how the services act on the network (for example, whether the service presents the computer's credentials or anonymous credentials to remote servers). O ServiceAccount enumeração fornece uma gama de privilégios para que você possa especificar exatamente os privilégios necessários para qualquer serviço específico.The ServiceAccount enumeration provides a range of privileges so that you can specify exactly the privileges you need for any particular service.

O LocalSystem valor define uma conta altamente privilegiada, mas a maioria dos serviços não exigem esse um nível de privilégio elevado.The LocalSystem value defines a highly privileged account, but most services do not require such an elevated privilege level. O LocalService e NetworkService membros de enumeração fornecem um nível de privilégio mais baixo para o contexto de segurança.The LocalService and NetworkService enumeration members provide a lower privilege level for the security context.

Observação

Os valores LocalService e NetworkService estão disponíveis somente na família Windows XP e Windows Server 2003.The values LocalService and NetworkService are available only on Windows XP and Windows Server 2003 family.

Aplica-se a

Veja também