- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
是否可以使用 Chef 访问其他用户的注册表?我有 chef-client 作为系统运行,我想修改 User1 的注册表?有没有办法做到这一点?
registry_key资源提供了一种访问 HKEY_Users 的方法,但我看不到将用户名映射到 SID 的方法。
最佳答案
这最终变得温和令人费解,看着它让我感到畏缩。但它似乎有效!
我想通过注册表修改另一个用户的环境变量,如 this Server Fault answer 中所述,但我也想用 Chef 创建用户。那么问题是 Windows 不会为用户创建注册表配置单元,直到他们登录。
如果相关用户确实存在,您可以跳到修改用户的注册表项。
Chef 内置的 execute
和 batch
资源似乎不支持提供密码,所以它看起来不像是 user
任何一个的属性都可以在 Windows 上使用。但是the official Chef Windows cookbook包含一个 windows_task
资源,该资源确实包含一个用于指定用户密码的属性。
现在的问题是授予相关用户“作为批处理作业登录”的本地安全策略权限。为此,我们可以使用 SecEdit .
确保您的 Recipe 依赖于官方的 Chef Windows Recipe ;在您的 Recipe 的 metadata.rb 文件中添加:
depends "windows"
这是 Chef Recipe 代码:
group "BatchJobUsers" do
append true
members ["AnotherUser"]
action :create
end
cookbook_file "BatchJobUsers-AddBatchLogonRight.inf" do
path "#{ENV['TEMP']}\\BatchJobUsers-AddBatchLogonRight.inf"
action :create_if_missing
end
execute "secedit" do
cwd "#{ENV['TEMP']}"
command "secedit /configure /db secedit.sdb /cfg BatchJobUsers-AddBatchLogonRight.inf"
end
windows_task "force-creation-of-AnotherUser-user-registry-hive" do
command "echo Force creation of AnotherUser user registry hive"
user "AnotherUser"
password "password-for-another-user"
action [:create, :run]
end
windows_task "force-creation-of-AnotherUser-user-registry-hive" do
action :delete
end
您需要向 COOKBOOK/files/default 目录添加一个名为 BatchJobUsers-AddBatchLogonRight.inf 的文件;它应该包含以下内容:
[Unicode]
Unicode=yes
[Version]
signature="$CHICAGO$"
Revision=1
[Privilege Rights]
SeBatchLogonRight = "BatchJobUsers"
确保您的 Recipe 依赖于官方的 Chef Windows Recipe ;在您的 Recipe 的 metadata.rb 文件中添加:
depends "windows"
在您的 Recipe 中,添加以下行:
::Chef::Recipe.send(:include, Windows::RegistryHelper)
然后您可以像这样在您的配方中使用函数 resolve_user_to_sid
:
get_user_sid = lambda { resolve_user_to_sid("USER_NAME") }
registry_key "Create environment variable registry keys" do
key lazy { "HKEY_USERS\\#{ get_user_sid.call }\\Environment"
values [{
:name => "Variable",
:type => :string,
:data => "variable_data"
}]
recursive true
action :create
end
必须延迟评估 key
属性(即在 Chef 运行配方的收敛阶段评估)以处理不存在的用户。
关于registry - 使用 Chef 访问另一个用户的注册表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22945786/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 6 年前。
如何打开注册表 Win98/98SE/Me 运行中输入regedit.exe 无权限限制 Win2000/XP 1·开始>>运行.中输入regedit 2.运行中
目录 前言 使用简单工厂改进 使用注册表改进 参考文章 前言 在上一篇文章中我们提到了抽象工厂模式初版代码的一些缺点:①客户端违反开闭原则②提供方违反开
目录 工厂方法模式的瑕疵 注册表 工厂方法模式的瑕疵 在前一篇笔记中我们介绍了工厂方法模式,示例的类图如下: 考虑一种情况:现在要在程序运行时,根据外部资源
我在一个带有一个主节点和两个节点的 AWS 集群中安装了 mesosphere,分别称为主节点、节点 1 和节点 2。主节点是可见的,节点是私有(private)的。 我得到一个默认运行的马拉松实例和
我想用 PHP 制作一个注册表,将他们的用户名和密码注册到我的 SQL 数据库中。这是我所拥有的: 配置.php: 索引.php: Deltalus Account Regi
我正在尝试将我的软件添加到注册表中,我找到了一些我可以使用的代码,但不是完整的工作代码 C/C++ 对我来说是新的,无法自己创建它。但基本思想是:检查 reg key 是否已设置(如果未创建)。 我能
我尝试创建一个注册 php 代码,这样当我不在计算机旁时我就可以注册人们,但由于某种原因,它不会创建表,也不会创建文件夹,即使不存在。 输出是: ( ! ) Notice: Undefined var
我使用 HKLM\Software\etc\etc 来存储我的基本设置,这基本上是我的程序及其相关数据库的位置。 我现在遇到的问题是我已经创建了一个 Windows 服务并且需要读取这些位置。我无法将
我正在尝试将我的软件添加到注册表中,我找到了一些我可以使用的代码片段,但不是完整的工作代码 C/C++ 对我来说是新的,我无法自己创建它。但这里是基本的想法:如果没有创建它,请检查是否设置了注册键。
1、保存以下代码到:c:\windows\system32\vdm.vbs 复制代码 代码如下: Dim Args Set Args = WScript.Argum
不懂注册表、VBS、批处理不要紧,只要会学、会吸收别人的精华,会查找资料,|论坛|百度|GOOGLE|,然后能用好,就非常不错了 贴一些搜集的文字放到这吧。(绿色是标题, 蓝色的是原作者
(绿色是标题, 蓝色的是原作者,红色的部分就是需要修改的部分,根据你自己的实际情况修改) ======打开迅闪菜单的同时连接虚拟磁盘的VBS====== Set WshShell = WScrip
简单使用 复制代码 代码如下: <?php require_once("Zend/Loader.php"); Zend_Loader::loadCl
但并不是每次都打开同一个键值,在每多时候我们还是习惯于Windows 98那样每次打开都在根目录中。 通过修改注册表可以达到这样的效果。打开HKEY_CURRENT_USER\Software\M
何谓REG文件 REG文件实际上是一种注册表脚本文件,双击REG文件即可将其中的数据导入到注册表中。利用REG文件我们可以直接对注册表进行任何修改操作,它对注册表的操作可以不受注册表编辑器被禁用的
我应该将哪些数据和位置添加到 Windows 注册表中以正确创建文件关联? 我问这个问题主要是因为我多年前编写的一些旧应用程序使用 Visual Studio .NET 的 Windows Insta
我想阻止对默认 docker.io 注册表的访问。为了安全/IP 保护,我们需要阻止对公共(public) Docker 集线器的推/拉访问。 已有许多尝试将此作为配置选项,但所有 PR 都不断被拒绝
Lua 提供了一个 "registry" “任何 C 代码都可以使用它来存储它需要存储的任何 Lua 值”。正如 here 所说,线程“与原始线程共享其全局环境” .但是我找不到任何地方说它是否共享注
我的软件在 HKCU\Software\mysoftware 中存储了一些值,这从来都不是问题。但是,我现在还在 HKCU\Software\mysoftware\Licenses 中存储了一些值 -
我是一名优秀的程序员,十分优秀!