Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Event Receiver active directory groups

$
0
0

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 Sub

 Anyone know the code to check if a user is in an A.D. group in a SharePoint Group?


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>