TIBCO Spotfire Community

Welcome to TIBCO Spotfire Community Sign in | Join | Help

Query the Analytics Server URL & the Username

This article targets: TIBCO Spotfire 2.1 and forward

 

From the day we released the platform APIs for TIBCO Spotfire, the most requested API feature with regards to connectivity has been to be able to query the Analytics Server URL and the user’s login name. This has actually been possible for quite some time using the ConnectivityService and the standard .NET User Operations Framework. The following snippet illustrates usage of the API in a tool that writes out the connectivity status of the application, the server URL, the username, and whether or not the user is an administrator.

 

public sealed class ConnectivityInformationTool : CustomTool<AnalysisApplication>
{
    public ConnectivityInformationTool() : base("Connectivity Information")
    {
        // Empty
    }

    protected override void ExecuteCore(AnalysisApplication context)
    {
        ConnectivityService service = context.GetService<ConnectivityService>();
        if (service.IsOnline)
        {
            // Print out info from the connectivity service
            Trace.WriteLine("Application is online");
            Trace.WriteLine("Server URL: " + service.ServerUri);
            
            // Print out user info
            IPrincipal userPrincipal = Thread.CurrentPrincipal;
            IIdentity userIdentity = userPrincipal.Identity;

            Trace.WriteLine("Current User: " + userIdentity.Name);
            Trace.WriteLineIf(userIdentity.IsAuthenticated, "User is authenticated");

            // The authentication states if the user was authenticated with
            // * a username and password, Windows Integrated Authentication, etc.
            Trace.WriteLine("Authentication Type: " + userIdentity.AuthenticationType);

            // Detect wether or not the user is an admin
            Trace.WriteLineIf(userPrincipal.IsInRole("administrator"), "User is an administrator");
        }
        else
        {
            Trace.WriteLine("Application is offline");
        }
    }
}
Published Dec 09 2008, 08:37 PM by Ehsan Yazdani Rating:
Comments
 

Per said:

Thanks for the tip. Now for a followup question:

If the current principal is owned by the Spotfire login system, does that mean that I can't get access to the "normal" principal in my extension to pass e.g. to a web service that uses integrated Windows Authentication as authentication mechanism?

/P

December 15, 2008 3:00 PM
 

Ehsan Yazdani said:

Although Spotfire controls the thread principal object, we never remove the possibility to retrieve the currenty logged in users' Windows identity. This is either used by creating a default NetworkCredential object or by calling WindowsIdentity.GetCurrent().

January 25, 2009 9:50 AM

About Ehsan Yazdani

Ehsan Yazdani is a developer with the TIBCO Spotfire and the TIBCO Spotfire Analytics Server Framework teams. His fields of expertise are network communication, web services, and framework extensibility.