简体   繁体   English

Powershell脚本添加证书并绑定到IIS-权限问题

[英]Powershell script to add certificate and binding to IIS - permissions problems

We are trying to programmatically add a new SSL certificate and a new binding to a site on IIS. 我们正在尝试以编程方式向IIS上的站点添加新的SSL证书和新的绑定。 We use powershell scripts to achieve so and it is working fine with a user who is local admin on the server. 我们使用powershell脚本来实现这一点,并且它与服务器上本地管理员的用户可以很好地工作。 The problem is, we can't have a user who is local admin on the web servers run this application in production. 问题是,我们不能让Web服务器上的本地管理员用户在生产环境中运行此应用程序。 It would be against company policies. 这将违反公司政策。 I want to know the minimal permission my user needs to be able to do this. 我想知道我的用户必须具备的最低权限才能执行此操作。 Those two commands are where I am blocked right now. 这两个命令是我现在被阻止的地方。

## Does nothing but no error. Works fine if I use my admin user.
Import-PfxCertificate -FilePath $path  cert:\localMachine\WebHosting\ -Password $mypwd -Exportable

## Give me : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
$newbinding = Get-WebBinding -Name $site -IPAddress $ip -Port 443 -Protocol "HTTPS" -HostHeader $hostheader 
$newbinding.AddSslCertificate("$thumbprint", "WebHosting")

I'm having difficulty finding a clear and definite answer of what permissions/configurations are needed. 我很难找到需要什么权限/配置的明确答案。 I had the same problem that this question before Cant add bindings to IIS programatically - redirection.config permissions (with a video!) . Cant之前以编程方式将绑定添加到IIS之前,我遇到了同样的问题-redirection.config权限(带有视频!) Now it still doesn't work but not the same error. 现在它仍然不起作用,但不是相同的错误。

Thank you 谢谢

If you are saying, that you are running this remotely on the IIS server, then PoSH by design for many cmdlets requires that the user executing the commands be in the target host local admin group. 如果要说的是要在IIS服务器上远程运行此程序,则针对许多cmdlet设计的PoSH要求执行命令的用户位于目标主机本地管理组中。 There is no way around that requirement. 无法绕开该要求。

Now, all that being said, why do you need a specific user run this vs using a scheduled task set with the necessary privs to execute the script? 现在,所有这些,为什么您需要一个特定的用户来运行它,而不是使用具有必需特权的计划任务集来执行脚本?

You could also consider leveraging PoSH JEA for such efforts. 您也可以考虑利用PoSH JEA进行此类工作。 It does not relieve the need for admin creds, but it does only grant them temporarily. 它不能免除管理员凭据的需要,但只会临时授予它们。

Just Enough Administration: Windows PowerShell security controls help protect enterprise data 足够的管理:Windows PowerShell安全控件有助于保护企业数据

Just Enough Administration (JEA)—the latest update that is now included with Windows Management Framework 5.0—is a security technology that helps organizations enforce information security by restricting IT administrative rights. Windows管理框架5.0现在包含的最新更新就是足够管理(JEA),它是一项安全技术,可以通过限制IT管理权限来帮助组织实施信息安全。 JEA provides a practical, role-based approach to set up and automate restrictions for IT personnel, and reduces the risks associated with providing users full administrative rights. JEA提供了一种实用的,基于角色的方法来设置和自动化对IT人员的限制,并降低了与为用户提供完全管理权限相关的风险。

JEA uses the built-in capabilities of the Windows PowerShell scripting environment. JEA使用Windows PowerShell脚本环境的内置功能。 Anything that you can manage with PowerShell, you can manage with JEA more securely. 您可以使用PowerShell进行管理的任何内容,都可以更安全地使用JEA进行管理。 JEA provides standardized methods of reducing administrative access with more granularity than traditional access control models. 与传统的访问控制模型相比,JEA提供了减少管理访问权限的标准化方法。

JEA allows specific users to perform designated administrative tasks on designated servers without giving them full administrator rights. JEA允许特定用户在指定的服务器上执行指定的管理任务,而无需授予他们完整的管理员权限。 JEA is based on Windows PowerShell-constrained run spaces, a technology used at Microsoft to help secure administrative tasks in environments like Microsoft Exchange Online. JEA基于Windows PowerShell约束的运行空间,这是Microsoft用来帮助保护Microsoft Exchange Online等环境中的管理任务安全的技术。

https://msdn.microsoft.com/en-us/library/dn896648.aspx https://msdn.microsoft.com/zh-CN/library/dn896648.aspx

Using JEA 使用JEA

This topic describes the various ways you can connect to and use a JEA endpoint. 本主题描述了可以连接和使用JEA端点的各种方式。

To use JEA interactively, you will need: •The name of the computer you are connecting to (can be the local machine) •The name of the JEA endpoint registered on that computer •Credentials for the computer that have access to the JEA endpoint 要交互使用JEA,您需要:•要连接的计算机的名称(可以是本地计算机)•在该计算机上注册的JEA端点的名称•可以访问JEA端点的计算机的凭据

https://docs.microsoft.com/en-us/powershell/jea/using-jea https://docs.microsoft.com/zh-CN/powershell/jea/using-jea

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM