Find enabled Polaris Staff Accounts

For a library you specify, the script lists:

  • User ID & Name
  • Total Number of Logins
  • Most Recent Login Date

It automatically filters out users marked as ‘suspended’, so you see data for ONLY active accounts.

How to Use:

  1. Set Library ID: Open the script and find SET @library = 'YOUR_LIBRARY_ID_HERE';. Replace the placeholder with your library’s actual OrganizationID.
    • This is the LIBRARY or PARENT ORG not the BranchID
  2. Run It: Execute the script in SQL Server Management Studio (SSMS).

Also, see: Find Dormant Polaris Users

-- Declare the @library variable.
-- Please replace the placeholder value 'YOUR_LIBRARY_ID_HERE' with the actual OrganizationID (PARENT ORG - NOT branch) of the library you want to query.
-- You can find OrganizationIDs in the Polaris.polaris.Organizations table.
DECLARE @library INT;
SET @library = '2'; -- Example: SET @library = 42;

-- Select Polaris User ID, Name, number of logins, and last login date
-- for users associated with the specified library or its parent organization.
SELECT
    pu.PolarisUserID,
    pu.Name AS UserName,
    COUNT(DISTINCT th.TransactionID) AS NumLogins,
    MAX(th.TranClientDate) AS LastLoginDate
FROM
    Polaris.polaris.PolarisUsers AS pu WITH (NOLOCK)
JOIN
    Polaris.polaris.Organizations AS o WITH (NOLOCK)
    ON o.OrganizationID = pu.OrganizationID
LEFT JOIN
    PolarisTransactions.polaris.TransactionHeaders AS th WITH (NOLOCK)
    ON th.TransactionTypeID = 7200 AND th.PolarisUserID = pu.PolarisUserID
WHERE
    @library IN (o.OrganizationID, o.ParentOrganizationID)
    -- Integrated logic from CLC_Custom_Is_User_Enabled function:
    -- This ensures the user is NOT marked as 'suspended' in UsersPPPP.
    AND NOT EXISTS (
        SELECT 1
        FROM Polaris.polaris.UsersPPPP up WITH (NOLOCK)
        WHERE up.PolarisUserID = pu.PolarisUserID
          AND up.AttrID = 659
          AND up.Value = 'suspended'
    )
GROUP BY
    pu.PolarisUserID,
    pu.Name
ORDER BY
    MAX(th.TranClientDate), -- Order by last login date first
    pu.Name; -- Then by user name