我试图在 AD 中为新创建的用户设置一些权限。创建文件夹后,我尝试设置各种权限,如下所示:
$Rights = [System.Security.AccessControl.FileSystemRights]::FullControl
$Inherit = @([System.Security.AccessControl.InheritanceFlags]::ContainerInherit,[System.Security.AccessControl.InheritanceFlags]::ObjectInherit)
$Propagation = [System.Security.AccessControl.PropagationFlags]::None
$Access =[System.Security.AccessControl.AccessControlType]::Allow
$ACL = New-Object System.Security.Principal.NTAccount "localdomain\$userprincipalname"
$objACE = New-Object System.Security.AccessControl.FileSystemAccessRule($ACL, $Rights, $Inherit, $Propagation, $Access)
$ACL = Get-Acl -Path $userDir
$ACL.AddAccessRule($objACE)
Set-ACL -Path $userDir -AclObject $ACL
我得到的错误与我传递给 AddAccessRule 的参数有关
Exception calling "AddAccessRule" with "1" argument(s): "Some or all identity references could not be translated."
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
但我在这里看不到任何错误,所以我真的很感激另一双眼睛。