Launching Report Builder from a Winform or Webform Application in SQL Reporting Services 2005

 

At times, you may need to launch Report Builder from your custom application as either the currently logged in user, or under a different, arbitrary identity. Here's how!

 

Regardless of the technique you use, you're basically going to be hitting the URL https://yourServerName/reportserver/reportbuilder/reportbuilder.application . Most of the samples below are really just doing the "heavy lifting" of creating the necessary process and/or user identity to run Report Builder under:

 

Winform / Current User:

 

Use System.Diagnostics.Process.Start to launch IE and point it to the URL above:

           

System.Diagnostics.Process.Start("IExplore.exe",

"https://localhost/reportserver/reportbuilder/reportbuilder.application");

           

Winform / Other Identity:

 

You'll still be using Process.Start, but you'll also need to utilize some of the new framework 2.0 StartInfo members to specify the username/domain/password, etc. You also will use the new SecureString class to pass your password to StartInfo:

           

ProcessStartInfo startInfo = new ProcessStartInfo(@"c:\program files\internet explorer\iexplore.exe");

startInfo.UserName = "TestUser";

startInfo.Domain = "aDomain";

startInfo.WorkingDirectory = @"c:\program files\internet explorer";

System.Security.SecureString sS = new System.Security.SecureString();

sS.Clear();

sS.AppendChar('P');

sS.AppendChar('a');

sS.AppendChar('s');

sS.AppendChar('s');

sS.AppendChar('W');

sS.AppendChar('o');

sS.AppendChar('r');

sS.AppendChar('d');

sS.AppendChar('1');

sS.AppendChar('2');

sS.AppendChar('3');

startInfo.Password = sS;

startInfo.Arguments = "https://localhost/reportserver/reportbuilder/reportbuilder.application";

startInfo.UseShellExecute = false;

startInfo.LoadUserProfile = true;

Process.Start(startInfo);

           

Another thing on this sample - You need to have LoadUserProfile set to true or Report Builder won't get installed (basically because the ClickOnce cache is located in C:\Documents and Settings\<username>\LocalSettings\Apps...so if you don't have a user profile loaded, there will be nowhere to drop the bits).

           

Webform / Current user:

 

Just use any technique you want to navigate to the https://yourServerName/reportserver/reportbuilder/reportbuilder.application URL

           

 

Webform / Other Identity:

 

 It doesn't appear that this is (easily) doable. If any of you come up with a cool workaround, please let me know and I’ll post it

           

 The basic problem is that regardless of how you launch the process (whether by Process.Start, LoginUserW and CreateProcessAsUser, etc.), it will get launched on the SERVER and will never become interactive. So, you may successfully LAUNCH an instance of IE, but the only place you'll see it is in task manager J There may be a way to locally launch an "impersonated" IE via JavaScript and RunAs, but I didn't have the patience to try and figure it out.