zoukankan      html  css  js  c++  java
  • ServiceAccount 枚举

    指定服务的安全上下文,安全上下文定义其登录类型。

    命名空间:  System.ServiceProcess
    程序集:  System.ServiceProcess(在 System.ServiceProcess.dll 中)

     成员名称说明
      LocalService 充当本地计算机上非特权用户的帐户,该帐户将匿名凭据提供给所有远程服务器。
      LocalSystem 服务控制管理员使用的帐户,它具有本地计算机上的许多权限并作为网络上的计算机。
      NetworkService 提供广泛的本地特权的帐户,该帐户将计算机的凭据提供给所有远程服务器。
      User 由网络上特定的用户定义的帐户。 如果为 ServiceProcessInstaller.Account 成员指定 User,则会使系统在安装服务时提示输入有效的用户名和密码,除非您为ServiceProcessInstaller 实例的 Username 和 Password 这两个属性设置值。

    当初始化 ServiceProcessInstaller 以指定要安装的服务的安全上下文时,请使用 ServiceAccount 枚举。 安全上下文指示服务在系统上的特权并指示服务在网络上如何操作(例如,服务是否将计算机的凭据或匿名凭据提供给远程服务器)。 ServiceAccount 枚举提供一系列特权,以便您可以为任何特定的服务指定正好需要的特权。

    LocalSystem 值定义具有高度特权的帐户,但大多数服务不需要这种提高的特权级别。 LocalService 和 NetworkService枚举成员为安全上下文提供较低的特权级别。

    说明说明

    值 LocalService 和 NetworkService 仅适用于 Windows XP 和 Windows Server 2003 系列。

    下面的代码示例演示如何通过 ServiceAccount 枚举,使用系统帐户的安全上下文安装新程序。

    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]");
        }
    }
     
  • 相关阅读:
    动态规划-重叠子问题
    百度 谷歌 Twitter,这么多短链接服务(Short Url)究竟哪家强?
    java中String初始化的两种方式
    bzoj 1218 [HNOI2003]激光炸弹
    Android TextView 横向滚动(跑马灯效果)
    混合高斯模型的EM求解(Mixtures of Gaussians)及Python实现源代码
    【Allwinner ClassA20类库分析】 2.free pascal语法及结构简析
    昂贵的聘礼
    C++11时间具体解释
    C++开发人脸性别识别教程(7)——搭建MFC框架之界面绘制
  • 原文地址:https://www.cnblogs.com/tianma3798/p/4146584.html
Copyright © 2011-2022 走看看