我试图获得某些活动目录用户对各种active对象的有效权限。我可以从UI中看到这些权限-

我正试着用Powershell实现这个。我已经尝试过dsacls和Get-Acls,但是这些都没有提供有效的权限。这两者都给出了“谁拥有访问/权限”,这与“谁有什么有效权限”不一样。这些文件也没有列出为有效访问提供上下文的所有细节。
任何关于如何以编程方式实现这一目标的建议都将受到欢迎。
更新-
这里的有效权限意味着在现实中基于继承或在不同级别上设置的其他规则允许对象具有哪些权限。
例如-
下面的示例中的所有属性在Get中都是不可见的。

在UI告诉不同的情况下,Get-Acl显示的另一个例子是,当我通过Get-ACL在OU上获取域管理员的权限时,在解析了ObjectType和InheritedObjectType中的值(使用圣地亚哥·斯夸尔松提到的get -有效访问函数)之后,我得到了-

而用户界面有效访问显示-

我的最终目标是使用powershell获得上述屏幕截图中的所有权限。
发布于 2021-05-26 03:16:07
这和你要找的东西很接近。来源为您提供更多细节。使用Get-ACL的访问控制列表并不像有效访问 on 那样容易阅读,我不认为有什么方法可以绕过它。我确实认为,一旦习惯了它,Get-ACL就会给出更多的细节,当您知道您在寻找什么\ filter这些ACL来获取您想要的内容时。
代码
function Get-EffectiveAccess {
[CmdletBinding()]
param(
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
[ValidatePattern('(?:(CN=([^,]*)),)?(?:((?:(?:CN|OU)=[^,]+,?)+),)?((?:DC=[^,]+,?)+)$')]
[alias('DistinguishedName')]
[string] $Identity,
[parameter()]
[alias('Domain')]
[string] $Server
)
begin {
$guid = [guid]::Empty
$GUIDMap = @{}
if($PSBoundParameters.ContainsKey('Server')) {
$domain = Get-ADRootDSE -Server $Server
}
else {
$domain = Get-ADRootDSE
}
$params = @{
SearchBase = $domain.schemaNamingContext
LDAPFilter = '(schemaIDGUID=*)'
Properties = 'name', 'schemaIDGUID'
ErrorAction = 'SilentlyContinue'
}
$adObjParams = @{
Properties = 'nTSecurityDescriptor'
}
if($PSBoundParameters.ContainsKey('Server')) {
$params['Server'] = $Server
$adObjParams['Server'] = $Server
}
$schemaIDs = Get-ADObject @params
$params['SearchBase'] = "CN=Extended-Rights,$($domain.configurationNamingContext)"
$params['LDAPFilter'] = '(objectClass=controlAccessRight)'
$params['Properties'] = 'name', 'rightsGUID'
$extendedRigths = Get-ADObject @params
foreach($i in $schemaIDs) {
if(-not $GUIDMap.ContainsKey([guid] $i.schemaIDGUID)) {
$GUIDMap.Add([guid] $i.schemaIDGUID, $i.name)
}
}
foreach($i in $extendedRigths) {
if(-not $GUIDMap.ContainsKey([guid] $i.rightsGUID)) {
$GUIDMap.Add([guid] $i.rightsGUID, $i.name)
}
}
}
process {
try {
$adObjParams['Identity'] = $Identity
$object = Get-ADObject @adObjParams
foreach($acl in $object.nTSecurityDescriptor.Access) {
if($guid.Equals($acl.ObjectType)) {
$objectType = 'All Objects (Full Control)'
}
elseif($GUIDMap.ContainsKey($acl.ObjectType)) {
$objectType = $GUIDMap[$acl.ObjectType]
}
else {
$objectType = $acl.ObjectType
}
if($guid.Equals($acl.InheritedObjectType)) {
$inheritedObjType = 'Applied to Any Inherited Object'
}
elseif($GUIDMap.ContainsKey($acl.InheritedObjectType)) {
$inheritedObjType = $GUIDMap[$acl.InheritedObjectType]
}
else {
$inheritedObjType = $acl.InheritedObjectType
}
[PSCustomObject]@{
Name = $object.Name
IdentityReference = $acl.IdentityReference
AccessControlType = $acl.AccessControlType
ActiveDirectoryRights = $acl.ActiveDirectoryRights
ObjectType = $objectType
InheritedObjectType = $inheritedObjType
InheritanceType = $acl.InheritanceType
IsInherited = $acl.IsInherited
}
}
}
catch {
$PSCmdlet.WriteError($_)
}
}
}示例
ExampleOU的组织单元的有效访问Get-ADOrganizationalUnit -Filter "Name -eq 'ExampleOU'" |
Get-EffectiveAccess | Out-GridViewExampleOU的组织单元的有效访问:Get-ADOrganizationalUnit -Filter "Name -eq 'ExampleOU'" -Server trustedDomain |
Get-EffectiveAccess -Server trustedDomain | Out-GridViewDistinguishedName属性:Get-EffectiveAccess -Identity 'OU=ExampleOU,DC=domainName,DC=com' | Out-GridViewexampleGroup的组的有效访问存储在变量中:$effectiveAccess = Get-ADGroup exampleGroup | Get-EffectiveAccessGet-ADOrganizationalUnit -Filter * | Select -First 10 |
Get-EffectiveAccess | Out-GridView示例
作为参考,这是完全控制在Get-ACL中的样子

与对此OU具有写权限但不具有BUILTIN\Administrators完全控制的相比

发布于 2021-05-30 01:53:36
您可以尝试使用PowerShellAccessControl模块,我认为这个模块的详细信息在这个youtube视频中包含了Get-EffectiveAccess函数。这应该能帮你得到信息。该模块已从微软PS画廊中删除。我不知道你怎么能从Github安装这个模块,我无法尝试,因为我正在使用Mac。
https://stackoverflow.com/questions/67696850
复制相似问题