Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Healthec
Frequent Visitor

Add User dynamically to Power bi report server

Hi All,

 

I am running one Power bi Report server where have the requirement like below:

 

I have one LDAP application where user uses windows authentication to login and go to the asp.net application.

I have requirement here to integrate power bi report server in asp.net application which i was able to complete.

Since my user id was not present in Power bi report server so when i accessed the Power bi report it asked for the credentials. When i added my user in Report server and did some browser settings to add report server domain name then without asking authentication report loads because i have used windows credentials.

I also verified here like in Report server > Settings > SiteSettings > Security in the textbox if i put the correct mail id of the person which is belongs to my organization then it accepts this and his username get and set in the report server and can see the user will get added with DomainName/Username.

 

Now we have many client in different-different region where for each client we are going to install report server separately.

But when those user will login first with there windows credentials for LDAP application and access the power bi report inside asp.net application for them again it will ask the credentials, Which we cannot set individually and manually in Report server.

 

Can we add the user in Report server dynamically like using some C# code or some other way?

Please suggest, It is an urgent taks.

 

3 REPLIES 3
Anonymous
Not applicable

You can utilize PowerShell code to automate Report Server security.

https://www.sqlshack.com/managing-ssrs-security-using-powershell-automation-scripts/

Hi Adharrison,

 

Thank you for quick reply. I have gone through the suggested link and get to know that using some powershell command i can add user and assign the role for him.

I believe below code should fullfill my requirement:

Clear-Host
$ReportServerUri = 'http://PorteousSQL1/ReportServer/ReportService2010.asmx?wsdl'
$InheritParent = $true
$GroupUserName = 'Domain\Deploy'
$RoleName = 'Publisher'
 
$rsProxy = New-WebServiceProxy -Uri $ReportServerUri -UseDefaultCredential
$type = $rsProxy.GetType().Namespace;
$policyType = "{0}.Policy" -f $type;
$roleType = "{0}.Role" -f $type;
#List out all subfolders under the parent directory
$items = $rsProxy.ListChildren("/", $true) | `
         SELECT TypeName, Path, ID, Name | `
         Where-Object {$_.typeName -eq "Folder"}
#Iterate through every folder 
foreach($item in $items)
{
	$Policies = $rsProxy.GetPolicies($Item.Path, [ref]$InheritParent)
	#Skip over folders marked to Inherit permissions. No changes needed.
	if($InheritParent -eq $false)
	{
		#Return all policies that contain the user/group we want to add
		$Policy = $Policies | 
		    Where-Object { $_.GroupUserName -eq $GroupUserName } | 
		    Select-Object -First 1
		#Add a new policy if doesnt exist
		if (-not $Policy) 
		{
		    $Policy = New-Object ($policyType)
		    $Policy.GroupUserName = $GroupUserName
		    $Policy.Roles = @()
			#Add new policy to the folder's policies
		    $Policies += $Policy
		}
		#Add the role to the new Policy
		$r = $Policy.Roles |
	        Where-Object { $_.Name -eq $RoleName } |
	        Select-Object -First 1
	    	if (-not $r) 
		{
	        	$r = New-Object ($roleType)
	        	$r.Name = $RoleName
	        	$Policy.Roles += $r
    		}
		#Set folder policies
		$rsProxy.SetPolicies($Item.Path, $Policies);
	}
}

In above script i have few questions like below:

a. ReportServiceUri could be same or i have to edit some thing here.

b. GroupUserName: I have to use like as per my organization : <Organization>/UserName

If that is the case then like in ReportServer > SiteSettings > Security when i add new user then when i type the new user mail id that is automatically fetch the related User in above format and set. Can i do the same here also?

c. This complete script can i run through web application?

 

Please suggest on above.

Hi Team,

 

Kindly provide and update on above asked. We need urgent fix for this issue.

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.