The forms authentication sample: http://msftrsprodsamples.codeplex.com/wikipage?title=SS2008%21Security%20Extension%20Sample&referringTitle=Home, is strictly for educational purpose only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples.

We frequently see the following different scenarios while trying configure this RS2008 Forms authentication sample on Windows Server 2008 machines:

Report Manager either gets hung or displays "Page cannot be displayed"

The error we see in the log files of Reporting Services is:

<Error>

library!ReportServer_0-6!d4c!03/18/2010-06:06:33:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.AuthenticationExtensionException: The Authentication Extension threw an unexpected exception or returned a value that is not valid: identity==null., ;
Info: Microsoft.ReportingServices.Diagnostics.Utilities.AuthenticationExtensionException: The Authentication Extension threw an unexpected exception or returned a value that is not valid: identity==null.

</Error>

Captured the dumps, and identified the following call stack:

<Error>

String: Warning: userIdentity is null! Modify your code if you wish to support anonymous logon.
at AuthenticationExtension.GetUserInfo(IIdentity& userIdentity, IntPtr& userId)
at WebServiceHelper.ConstructRSServiceObjectFromSecurityExtension()
at Global.ConstructRSServiceFromRequest(String item)
at Global.get_Service()
at Global.DispatchRequest()
at Global.Application_AuthenticateRequest(Object sender, EventArgs e)
at SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at ApplicationStepManager.ResumeSteps(Exception error)
at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
at HttpRuntime.ProcessRequest(HttpWorkerRequest wr)
at RsHttpRuntime.ProcessRequest(IRsHttpPipeline rsHttpPipeline)

</Error>

This primarily is being thrown from the GetUserInfo method of AuthenticationExtension.

 public void GetUserInfo(out IIdentity userIdentity, out IntPtr userId)
{
// If the current user identity is not null,
// set the userIdentity parameter to that of the current user
if (HttpContext.Current != null
&& HttpContext.Current.User != null)
{
userIdentity = HttpContext.Current.User.Identity;
}
else
// The current user identity is null. This happens when the user attempts an anonymous logon.
// Although it is ok to return userIdentity as a null reference, it is best to throw an appropriate
// exception for debugging purposes.
// To configure for anonymous logon, return a Gener
{
System.Diagnostics.Debug.Assert(false, "Warning: userIdentity is null! Modify your code if you wish to support anonymous logon.");
throw new NullReferenceException("Anonymous logon is not configured. userIdentity should not be null!");
}

// initialize a pointer to the current user id to zero
userId = IntPtr.Zero;
}

In the above code, we are explicitly throwing the exception while the User is Null. The browser when is not capable of displaying the exception, it will either get hung or lead us to an error "Page Cannot be displayed"

This code can be modified to the following:

public void GetUserInfo(out IIdentity userIdentity, out IntPtr userId)
{
// If the current user identity is not null,
// set the userIdentity parameter to that of the current user
if (HttpContext.Current != null
&& HttpContext.Current.User != null)
{
userIdentity = HttpContext.Current.User.Identity;
}
else
// The current user identity is null. This happens when the user attempts an anonymous logon.
// Although it is ok to return userIdentity as a null reference, it is best to throw an appropriate
// exception for debugging purposes.
// To configure for anonymous logon, return a Gener
{
userIdentity = new GenericIdentity("test");
System.Diagnostics.Debug.Assert(true);
}

// initialize a pointer to the current user id to zero
userId = IntPtr.Zero;
}

This helps us suppress the exception and set the userIdentity value to a dummy value.

During the Logon screen or trying to Logon, "An error occured while attempting to get the ReportServer Url. Invalid namespace"

The below stated code being used in AuthenticationUtilities class, does build the URL for Reporting Services to be used by the Forms authentication sample.

private const string wmiNamespace = @"\root\Microsoft\SqlServer\ReportServer\{0}\v10";
private const string rsAsmx = @"/ReportService2005.asmx";

Method: GetReportServerURL

string fullWmiNamespace = @"\\" + machineName + string.Format(wmiNamespace, instanceName);

The WMI Namespace can vary, and most of the time it would be of the Format, RS_<InstanceName>. If this is a default instance, the WMI Namespace for RS can be of the format RS_MSSQLSERVER. The WMI Namespace can be confirmed from ReportingServices.MOF file under the ReportServer\bin directory of the RS Installation directory.

This namespace should be referred properly to fix the above stated error.