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]");
        }
    }
     
  • 相关阅读:
    查看CLOUD系统级IIS日志
    采购订单设置采购部门为缺省值
    单据头数据复制到单据体
    CLOUD设置过滤方案不共享
    BZOJ 4773: 负环 倍增Floyd
    LOJ #539. 「LibreOJ NOIP Round #1」旅游路线 倍增floyd + 思维
    BZOJ 4821: [Sdoi2017]相关分析 线段树 + 卡精
    一些常用公式/技巧
    BZOJ 4517: [Sdoi2016]排列计数 错排 + 组合
    BZOJ 3162: 独钓寒江雪 树的同构 + 组合 + 计数
  • 原文地址:https://www.cnblogs.com/tianma3798/p/4146584.html
Copyright © 2011-2022 走看看