powershell - 绑定到 AD LDS 并更改用户密码
问题描述
我正在尝试以务实的方式(使用 powershell)绑定到 AD LDS(ADAM)目录并更改用户密码。
我尝试使用此 cmdlet
Set-ADAccountPassword -Identity $identity -Server 'localhost:389' -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "$password" -Force);
如果我手动使用它可以正常工作,但如果由服务完成,即使服务以与手动运行时相同的用户身份运行,它也不起作用。如果有人有任何想法为什么会这样,我将不胜感激。
function JICSpwd {
Param(
[string]$username,
[string]$password
)
if ($username -and $password) {
if ($username -notmatch '^\d+$'){
$id_num = $(getID $username);
} else {
$id_num = $username;
}
try {
if ($id_num){
$identity = "CN=$id_num,OU=PortalUsers,CN=Portal,O=Jenzabar,C=US";
Set-ADAccountPassword -Identity $identity -Server 'my.domain.edu:389' -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "$password" -Force);
Write-Log -Message "Successfully updated JICS password ($id_num)";
}
} catch [Exception] {
Write-Log -Message "Failed to update JICS password ($username)" -Level Warn;
Write-Log -Message "---> $_.Exception.GetType().FullName, $_.Exception.Message" -Level Warn;
}
}
}
解决方案
推荐阅读
- delphi - Delphi 10.3 - 带有 HashMap 的 Zebra 打印机的 Android Intent
- css - CSS箭头不直
- csv - 当文本(在定义的文本分隔符内)包含逗号时,SSIS 无法读取 .CSV 文件
- laravel - laravel-localization 在运行服务器时给我错误
- visual-studio-code - 如何对 vscode 调试器扩展进行端到端测试?
- python-3.x - 如何从 django HttpRequest 对象执行 url 传递的键 = 值对
- laravel - Eloquent - 从闭包中向主查询实例添加查询
- php - PHP:为什么 imagepng() 函数在保存图像时会增加大小?
- java - 模型映射器异常:仅在 Docker 中无法将 java.lang.String 转换为 java.lang.Integer
- javascript - 在 React 组件中测试 API 调用