Login / Register  search  syndication  about

          Ryan Farley's Blog

Ryan Farley on .NET Development with a focus on CRM Development for SalesLogix

Passing Connection Information from SalesLogix Web to Another Website

When integrating another system, application, or website with SalesLogix there are many options. If you're need to make connections to the SalesLogix database via the provider using user credentials you either need to prompt the user for login (again) or you can pass the connection information along to the other system.

It's easy enough to get the connection information using the DataService in SalesLogix. However, you don't really want to pass around a complete connection string around, especially since it will have the user's username and password in it. However, you can get the user's authentication token and then pass that to another system. It can use that authentication token to get all the connection values and form a valid connection string. Let's take a look.


Retrieving the current user's Authentication Token

To retrieve the user's authentication token, you can use the AuthenticationProvider service.

var authService = ApplicationContext.Current.Services.Get<IAuthenticationProvider>();
string authToken = authService.AuthenticationToken;

The authentication token will look like a long string of letters and numbers. You can pass this to some other website so that website/webpage can log into SalesLogix as that same user without prompting the user for their username and password. Let's look at what to do with this authentication token.


Decrypting and Using the Authentication Token

Once the other website or webpage has the Authentication Token all you need to do is convert it back to a stream and then read out the values from it. Then you have everything you need to form a valid connection string to the SalesLogix database as the user whose authentication token you have.

// In this code the "authToken" variable holds the authentication token value
// passed from SalesLogix Web (see code above)

using (var stream = new MemoryStream(Convert.FromBase64String(authToken)))
{
    using (var reader = new StreamReader(stream))
    {
        string UserName = reader.ReadLine();
        string Password = reader.ReadLine();
        string UserId = reader.ReadLine();
        string Database = reader.ReadLine();
        string Alias = reader.ReadLine();
        string Server = reader.ReadLine();
        string ExtendedProperties = reader.ReadLine();
        string Provider = reader.ReadLine();
        string UserType = reader.ReadLine();

        string ConnectionString = string.Format(
                "Provider={5};Persist Security Info=True;Initial Catalog={1};Data Source={0};User ID={3};Password=\"{4}\";Extended Properties=\"{2}\"", 
                Server, Database, ExtendedProperties, UserName, Password, Provider
            );
    }
}

Pretty easy and the other external website or password didn't need to ask the user again for credentials or store a connection string locally.


Note if passing the Auth Token in a URL

If you are passing this authorization token from SalesLogix to another website or webpage via a parameter in the URL, you must encode the token otherwise any contained "+" chars will break the string (since that will be interpreted in the URL as a space).

On the SalesLogix side, encode the token using something like this:

authToken = System.Web.HttpUtility.UrlEncode(authToken);

Then, on the receiving side, grab the token from the URL and then decode is using something like this:

authToken = System.Web.HttpUtility.UrlDecode(authToken);

Then all will work fine and you can proceed to get the connection values from the token.

What's This?
  
Bookmark and Share

About Ryan Farley

   Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix since 2001 and believes in sharing with the community. He loves C#, Javascript, Python, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

View the SalesLogix Mobile Seveloper Series
View the SalesLogix SData Developer Series
View the Git for the SalesLogix Developer series



Related Content
   Can I Bind an Attachment to a Specific Activity in Infor CRM version 7.54?
Recently I had a user ask if they could bind an attachment to a specific Activity within Infor CRM??
Posted on Jul 07, 2015 by Dale Richter to Infor CRM Questions & Answers
 
   Infor CRM (Formerly Saleslogix) Iterating through all tabs on a Page
 Using the TabWorskpace you can iterate through all the tabs on a page and do something with them, l
Posted on Jun 19, 2015 by Kris Halsrud to Kris Halsrud's Blog
 
   Infor CRM (Formerly Saleslogix) Hiding Tabs at Runtime Without Using Modules
 As Ryan wrote a long time ago, you can create a module and add it to a page in the Infor CRM web cl
Posted on Jun 10, 2015 by Kris Halsrud to Kris Halsrud's Blog
 
   How I assign ownership to a group of Leads in Infor CRM?
There is a tool within Infor CRM to align Accounts to different Account Owners. It is called Territory Re
Posted on Jun 05, 2015 by Dale Richter to Infor CRM Questions & Answers
 
   Infor CRM (Formerly Saleslogix) Adding a Client Side Confirmation on a Dependency Lookup in the Web Client
 We recently had a client who wanted to have a user confirmation prompt before a user was allowed to
Posted on May 28, 2015 by Kris Halsrud to Kris Halsrud's Blog
 
Comments

 

Jeff LeFevre said:

Ryan,

I need to pass the token from SLX to another web site like you describe above. My site has to be in a new browser window. Not inside SLX.

My problem is I need to do it from a Menu item.

In the Nav Url for the item, I am using javascript:window.open('xx.xx.xx/default.aspx' + , 'My Website', 'status=no,width=950,height=700');

This launches the site.  My problem is how do I get the current user's Authentication Token and put in the url string such as....

...default.aspx?token=.....

If there is a better way to call my new web site please let me know.

Please help.

April 16, 2012 10:38 AM
 

Ryan Farley said:

If you're doing that from a menu item you would need to set the location that the menu goes to at runtime. You can refer to this post on getting access to the menu items from a module: customerfx.com/.../creating-modules-for-saleslogix-web-and-hiding-toolbar-items-at-runtime.aspx This article looks are removing menu items in code, but once you have the menu item you could set it's link location just the same (and append on the authentication token)

Ryan

April 16, 2012 6:00 PM

Leave a Comment

(required)  
(optional)
(required)  
Add
All contents Copyright © 2015 Customer FX Corporation
Customer FX Corporation
2324 University Avenue West, Suite 115
Saint Paul, Minnesota 55114
Tel: 800.728.5783

  Follow @CustomerFX on twitter
Follow the best news, tips, and articles
  Subscribe to Customer FX on youtube
Watch SalesLogix tutorial videos from Customer FX
Login / Register