Finding What Users are Logged In from within the Infor CRM (Saleslogix) Web Client

The Infor CRM licensing model and enforcement is a component of the SLX Server component and is handled at the Saleslogix OLE DB Proivder level. You have access to this information from within the Administrator application via the color coded icons next to the user list showing green for those users currently logged in. There isn’t really a well defined way of getting this information any other way.

Until now!

Digging around in the web assemblies, you can find severl methods that look promising. The Sage.SalesLogix.Security assembly has a couple of promising classes called the LicenseService and the UserManagementService. Both of these have several common methods that look to be the winners. GetLicenseCount, GetLicenseAvailableCount, GetLicenseUsedCount all seem to be exactly what we want. They each accept a parameter of the LicenseType you want to get details on. To use you can do something like:

    Sage.SalesLogix.Security.UserManagementService userv = new Sage.SalesLogix.Security.UserManagementService();
    int concurrentTotal = userv.GetLicenseCount(Sage.Entity.Interfaces.UserType.Concurrent); //it does work!!
    int x = userv.GetLicenseUsedCount(Sage.Entity.Interfaces.UserType.Concurrent); //doesnt work, returns 0
    int z = userv.GetLicenseAvailableCount(Sage.Entity.Interfaces.UserType.Concurrent); //doesnt work, provides total seat license for all types
    int y = userv.GetLoggedInUsers().Count; //Doesnt work, returns 0

As you can tell by the comments there are problems with these methods. problems meaning they don’t work. in either service class.

Sigh.

Fear not, there is one more place that looks promising, the SLXConcurrentLicenseProvider class. That one has a lot less in it and the code that is there is not very helpful but it did lead me down the rabbit hole I needed to follow. Using that code as a basis I discovered the helpful SLXSystemProvider class. Using this class is the ticket. From here we gain access through COM to the provider level licensing details that you see in the Administrator! Lets take a look at how we can use it.

You can invoke this class like so:

using (Sage.SalesLogix.SLXSystemProvider provider = new Sage.SalesLogix.SLXSystemProvider())

With that present, there are now 2 key methods: GetConcurrentAvailable and LoggedInUsers

GetConcurrentAvailable accepts 3 parameters, the SLX server, the SLX port, and the Server Connection Name. All of these can be accessed using the DataService, like so:

        var datasvc = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Data.IDataService>() as Sage.Platform.Data.IDataService;
        int concurrentAvailabelCnt = provider.GetConcurrentAvailable(datasvc.Server, 1706, datasvc.Alias);

The LoggedInUsers method just takes one parameter, the SLX Server Alias:

        var datasvc = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Data.IDataService>() as Sage.Platform.Data.IDataService;
        string loggedInIds = string.Join(",", provider.LoggedInUsers(datasvc.Alias));

The GetConcurrentAvailable returns how many available concurrent licenses are free to use. It returns an integer.
The LoggedInUsers method returns the UserID of each logged in user.

By using each UserID returned we can parse out who they are using the normal entity model. Note, the LoggedInUser shows each user login and across any platform so if a user is logged in 3 times (Windows client, Architect, Web Client) then you see there name 3 times. Lets look at a full code block that can show details of who is logged in and breaking that down by concurrent and not:

    Sage.SalesLogix.Security.UserManagementService userv = new Sage.SalesLogix.Security.UserManagementService();
    int concurrentTotal = userv.GetLicenseCount(Sage.Entity.Interfaces.UserType.Concurrent); //it does work!!
    int x = userv.GetLicenseUsedCount(Sage.Entity.Interfaces.UserType.Concurrent); //doesnt work, returns 0
    int z = userv.GetLicenseAvailableCount(Sage.Entity.Interfaces.UserType.Concurrent); //doesnt work, provides total seat license for all types
    int y = userv.GetLoggedInUsers().Count; //Doesnt work, returns 0
    
    using (Sage.SalesLogix.SLXSystemProvider provider = new Sage.SalesLogix.SLXSystemProvider())
    {
        var datasvc = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Data.IDataService>() as Sage.Platform.Data.IDataService;

        int concurrentAvailabelCnt = provider.GetConcurrentAvailable(datasvc.Server, 1706, datasvc.Alias);
        string loggedInIds = string.Join(",", provider.LoggedInUsers(datasvc.Alias));
        string[] loggedIns = loggedInIds.Split(',');
        string concurrentUsers = string.Empty;
        string otherUsers = string.Empty;
        foreach(string loggedIn in loggedIns)
        {
            Sage.Entity.Interfaces.IUser usr = Sage.Platform.EntityFactory.GetById<Sage.Entity.Interfaces.IUser>(loggedIn.Trim());
            if (usr != null)
            {
                if (usr.Type == Sage.Entity.Interfaces.UserType.Concurrent) concurrentUsers += usr.UserInfo.UserName + System.Environment.NewLine;
                if (usr.Type != Sage.Entity.Interfaces.UserType.Concurrent) otherUsers += usr.UserInfo.UserName + System.Environment.NewLine;
            }
                
        }
        throw new Sage.Platform.Application.ValidationException(string.Format(
            "Concurrent License{3}  Total:{0}{3}  Used:{1}{3}  Free:{2}{3}{3}Concurrent Users:{3}{4}{3}{3}Other Users:{3}{5}",
            concurrentTotal, 
            concurrentAvailabelCnt, 
            concurrentTotal-concurrentAvailabelCnt, 
            System.Environment.NewLine,
            concurrentUsers,
            otherUsers));        
    }
ABOUT THE AUTHOR

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!