I have created an Event Receiver that works if a user's account is directly in a SharePoint Group. But my users are in A.D. groups and the A.D. groups are in SharePoint Groups. My Event Receiver checks to see if the current user is in a certain group. Here is my code:
Public Overrides Sub ItemDeleting(properties as SPItemEventProperties)
MyBase.ItemDeleting(properties)
Dim stCurrentUser As SPUser
Dim stGroup As SPGroup
stCurrentUser = properties.OpenWeb().CurrentUser
For Each stGroup In stCurrentUser.Groups
If (stGroup.Name.Equals("test group name")) Then
properties.Cancel = True
properties.ErrorMessage = "Deleting Items Not Allowed!"
End If
Next
End SubAnyone know the code to check if a user is in an A.D. group in a SharePoint Group?