【问题标题】:How to check is a user is in a Domain group?如何检查用户是否在域组中?
【发布时间】:2014-10-13 14:02:14
【问题描述】:

我想检查用户的组成员身份。组取自 ldap 并插入到域中。目前我尝试了这样的事情......

#Powershell.ps1
$CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$wp = New-Object System.Security.Principal.WindowsPrincipal($CurrentUser)
# I have in my domain a group called 'dom_group'
if ( $wp.IsInRole('dom_group') ) {
     "Expected to be true"
} else {
     "Unexpected False"
}
#Unexpected False

很遗憾,这只适用于本地团体。

如何根据域组“dom_group”检查当前使用的组成员身份?

【问题讨论】:

    标签: .net windows security powershell


    【解决方案1】:

    您的代码可以使用,但您必须使用您的域名来限定组名:$wp.IsInRole('mydomain\dom_group')$wp.IsInRole('dom_group@mydomain')

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-29
      • 2011-10-02
      • 1970-01-01
      • 2014-05-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-14
      相关资源
      最近更新 更多