Thursday, November 13, 2014

Find Active Directory Group - Report Security

Report Builder has a built-in function for User ID, but if you want to limit access or include expressions based on Active Directory Groups you will have to use custom code.

In the Report Properties, go to the Custom Code window and type in the following code:


Public Function IsMemberOfGroup() As Boolean

If System.Threading.Thread.CurrentPrincipal.IsInRole("Your AD Group Name") Then
    Return True
Else
   Return False
End If
End Function

 You can call the code in any expression window by using the following code: Code.FunctionName() 

Change image depending on Ad Security Group

=IIF(Code.IsMemberOfGroup()="True", "questionmarkrpt","questionmarkrptblank")

 Go to a specific link depending on AD Security Group. 

=IIF(Code.IsMemberOfGroup() = "True", "javascript:void(window.open('http://Google.com', '_blank'))", "javascript:void(window.open('http://yahoo.com', '_blank'))")

No comments:

Post a Comment