How to determine which AD security groups of the current user are in the SSRS report?

I need to determine which security groups are users from the SQL Server Reporting Services report. Access to the report will be determined by membership in one of two groups: report_name_summary and report_name_detail. When a user runs a report, we want to be able to use their membership (or lack of membership) in the report_name_detail group to determine if a tree is allowed.

I donโ€™t know how to get out of the box to gain access to membership in the current AD users security group, but I am open to any suggestions about the possibility of access to this information from the report.

+3
source share
2 answers

You can add custom code to the report. There are some examples in this link .

Theoretically, you should be able to write some code like this, and then use the return value to show / hide what you want. However, you may have rights issues with this method.

Public Function ShouldReportBeHidden() As Boolean
Dim Principal As New System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent())
If (Principal.IsInRole("MyADGroup")) Then
    Return False
Else
    Return True
End If
End Function

Alternatively , you can add your detail report as a summary report of your summary report. You can then use the built-in security features for SSRS to restrict access to your report.

+5
source

In Reporting Services, simply use:

Public Function IsMemberOfGroup() As Boolean

If System.Threading.Thread.CurrentPrincipal.IsInRole("MyADGroup") Then
    Return True
Else
    Return False
End If

End Function

as indicated in this publication

Note. This works as soon as the report is deployed to the server, but not in the IDE.

+1

Source: https://habr.com/ru/post/1699210/


All Articles