User Member of AD Group

 

This script looks if the actually logged on User is in an specified Active Directory Group: (in this Example: ActiveDirectoryGroup1 or ActiveDirectoryGroup2)

Dim WSHShell, objNET, objSysInfo, objUser, strUserDN, strGroups, Group, GroupName
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set objNET = WScript.CreateObject("WScript.Network")
Set objSysInfo = WScript.CreateObject("ADSystemInfo")
strUserDN = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUserDN)
  
strGroups = objUser.GetEx("memberOf")   
For Each Group in strGroups
Set ThisGroup = GetObject("LDAP://" & Group)
GroupName = ThisGroup.CN

Select Case GroupName
   Case "ActiveDirectoryGroup1"
Wscript.echo "User is Member of ActiveDirectoryGroup1"
WScript.Quit(0) 
   Case "ActiveDirectoryGroup2"
        Wscript.echo "User is Member of ActiveDirectoryGroup2"
End Select
Next
positive Bewertung({{pro_count}})
Beitrag bewerten:
{{percentage}} % positiv
negative Bewertung({{con_count}})

DANKE für deine Bewertung!

Fragen / Kommentare


Durch die weitere Nutzung der Seite stimmst du der Verwendung von Cookies zu Mehr Details