Verify user is in a AD group
By nater

Option Explicit

Dim network

'***************************group membership Modify this to add/change groups*********************************
Const MSGROUP1 = "Domain Admins"
Const MSGROUP2 = ""
Const MSGROUP3 = ""
Const MSGROUP4 = ""
'*************************************************************************************************************


Set network = CreateObject("WScript.Network")


If isMemberOf(MSGROUP1) Then
WScript.Echo "you are a Administrator"
WScript.Quit
end if



Function isMemberOf(ByVal group)
Dim user, found, temp
found = False
Set user = GetObject("WinNT://" & CreateObject("WScript.Network").UserDomain & "/" &

CreateObject("WScript.Network").UserName )
For Each temp In user.Groups
If UCase(temp.Name) = UCase(group) Then
found = True
Exit For
End If
Next
isMemberOf = found
End Function

Rating:


4/5 based on 1 vote. The median rating is 4.

Submitted: 11/19/10 (Edited 11/19/10)

Description: Verify a user is in a particular AD group and then can perform an action. Good for login scripts.

Tags:

Views: 69 views. Averaging 0 views per day.
In the most recent 30 day period, there've been 0 views.

Similar Articles:
NPD Group: 1/3 of All Smartphones Sold are Now Pre
NPD Group: 1/3 of All Smartphones Sold are Now Pre
Group Protests Netflix VPN Ban With Billboard at N
Group Protests Netflix VPN Ban With Billboard at N
Group Protests Netflix VPN Ban With Billboard at N