ServiceAccount Sabit listesi

Tanım

Bir hizmetin oturum açma türünü tanımlayan güvenlik bağlamını belirtir.

public enum class ServiceAccount
public enum ServiceAccount
type ServiceAccount = 
Public Enum ServiceAccount
Devralma
ServiceAccount

Alanlar

LocalService 0

Yerel bilgisayarda ayrıcalıklı olmayan bir kullanıcı olarak davranan ve herhangi bir uzak sunucuya anonim kimlik bilgileri sunan bir hesap.

LocalSystem 2

Yerel bilgisayarda kapsamlı ayrıcalıklara sahip olan ve ağdaki bilgisayar olarak görev yapan, hizmet denetim yöneticisi tarafından kullanılan bir hesap.

NetworkService 1

Kapsamlı yerel ayrıcalıklar sağlayan ve bilgisayarın kimlik bilgilerini herhangi bir uzak sunucuya sunan bir hesap.

User 3

Ağdaki belirli bir kullanıcı tarafından tanımlanan bir hesap. Üyenin belirtilmesiUser, örneğinizin ServiceProcessInstaller hem hem de Username özelliklerinin değerlerini ayarlamadığınız sürece, hizmet yüklendiğinde sistemin geçerli bir kullanıcı adı ve Password parola istemesine neden Account olur.

Örnekler

Aşağıdaki kod örneği, sistem hesabının güvenlik bağlamını ServiceAccount kullanarak yeni programları yüklemek için numaralandırmanın nasıl kullanılacağını gösterir.

#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

Açıklamalar

ServiceAccount Yüklediğiniz hizmetin güvenlik bağlamını belirtmek için bir ServiceProcessInstaller başlatırken numaralandırmayı kullanın. Güvenlik bağlamı, bir hizmetin sistemde sahip olduğu ayrıcalıkları ve hizmetlerin ağda nasıl davrandığını gösterir (örneğin, hizmetin bilgisayarın kimlik bilgilerini veya anonim kimlik bilgilerini uzak sunuculara sunup sunmadığı). Numaralandırma ServiceAccount , belirli bir hizmet için tam olarak ihtiyacınız olan ayrıcalıkları belirtebilmeniz için bir dizi ayrıcalık sağlar.

LocalSystem değeri yüksek ayrıcalıklı bir hesap tanımlar, ancak çoğu hizmet bu kadar yükseltilmiş bir ayrıcalık düzeyi gerektirmez. LocalService ve NetworkService numaralandırma üyeleri, güvenlik bağlamı için daha düşük bir ayrıcalık düzeyi sağlar.

Not

ve NetworkService değerleri LocalService yalnızca Windows XP ve Windows Server 2003 ailesinde kullanılabilir.

Şunlara uygulanır

Ayrıca bkz.