ServiceAccount 列挙体
アセンブリ: System.ServiceProcess (system.serviceprocess.dll 内)
構文
Public Enumeration ServiceAccount
メンバ名 | 説明 | |
---|---|---|
LocalService | ローカル コンピュータ上の特権を与えられていないユーザーとして機能するアカウント。このアカウントは、匿名の資格情報をリモート サーバーに提示します。 | |
LocalSystem | ローカル コンピュータ上で広範囲の特権を持ち、ネットワーク上のコンピュータとして機能するアカウント。このアカウントは、サービス コントロール マネージャが使用します。 | |
NetworkService | 広範囲のローカル特権を提供するアカウント。このアカウントは、コンピュータの資格情報をリモート サーバーに提示します。 | |
User | ネットワーク上の特定のユーザーによって定義されたアカウント。ServiceProcessInstaller.Account メンバに対して User を指定すると、ServiceProcessInstaller インスタンスの Username プロパティ値と Password プロパティ値を設定していない限りは、サービスのインストール時に有効なユーザー名とパスワードを入力するように要求されます。 |
ServiceProcessInstaller を初期化するときに ServiceAccount クラスを使用して、これからインストールするサービスのセキュリティ コンテキストを指定します。セキュリティ コンテキストは、システムにおいてサービスに与えられる特権と、ネットワーク上でのそのサービスの動作 (たとえば、サービスがコンピュータの資格情報または匿名の資格情報をリモート サーバーに提示するかどうか) を示します。ServiceAccount クラスは、特定のサービスに必要な特権を正確に指定できるように、一定範囲に含まれる複数の特権をまとめて提供します。
LocalSystem 値は、高レベルの特権を与えられたアカウントを定義しますが、ほとんどのサービスにはそれほど高い特権レベルは必要ありません。LocalService 列挙体メンバと NetworkService 列挙体メンバは、セキュリティ コンテキストに対して、それよりも低い特権レベルを提供します。
メモ |
---|
LocalService 値および NetworkService 値は Windows XP と Windows Server 2003 ファミリでだけ使用できます。 |
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 End Class
using System; using System.Collections; using System.Configuration.Install; using System.ServiceProcess; using System.ComponentModel; [RunInstallerAttribute(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); } }
#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; [RunInstallerAttribute(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 ); } };
import System.*; import System.Collections.*; import System.Configuration.Install.*; import System.ServiceProcess.*; import System.ComponentModel.*; /** @attribute RunInstallerAttribute(true) */ public class MyProjectInstaller extends 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.set_Account(ServiceAccount.LocalSystem); // The services are started manually. serviceInstaller1.set_StartType(ServiceStartMode.Manual); serviceInstaller2.set_StartType(ServiceStartMode.Manual); // ServiceName must equal those on ServiceBase derived classes. serviceInstaller1.set_ServiceName("Hello-World Service 1"); serviceInstaller2.set_ServiceName("Hello-World Service 2"); // Add installers to collection. Order is not important. get_Installers().Add(serviceInstaller1); get_Installers().Add(serviceInstaller2); get_Installers().Add(processInstaller); } //MyProjectInstaller } //MyProjectInstaller
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- ServiceAccount 列挙体のページへのリンク