11 Replies Latest reply on Apr 29, 2015 10:45 AM by Mark Elmore

    Scripting Help..Card Swipe Logon

    Mark Elmore Adventurer

      Ok..so I am trying to setup a single sign on type thing using user card swipes. I have two scripts that are the provided Pharos scripts which I have modified. The first script, CardSwipe Logon, does exactly what it should do. However the problem comes in with the Billing script. We use CSGold, and the billing script is pointing to the billplug.exe; however, it is not taking the raw card data and passing it. Up front, I am not a programmer so getting it this far is pretty amazing for me. I am well aware that I may have missed something or otherwise left something out. Ideally I would like to not have to use a billing script to parse this if there is a way to get the logon script to pass the raw card data along. I have attached the scripts for review. Any help would be most appreciated.

       

      Some background on our setup:

      Our university uses IDs in the following format; (aaaXXXXXXXXX)

      Our users in Pharos are in the following format:

           Logon ID: aaaXXXXXXXXX

           First Name:

           Last Name:

           Alias: aaaXXXXXXXXX

           Role: User

           Active: Yes

           Card ID:

      The CardSwipe Logon script is checking for accounts based on the Logon ID field after some processing of the raw card data (;XXXXXXXXX=XXXX?). <--- That part works fine.

        • Re: Scripting Help..Card Swipe Logon
          Steven English Guide

          Hi Mark,

           

          My recollection is that the Card ID is the default value sent to your billing gateway, but from first glance I can see a number of items that are not correct (most notable the lack of escaping the slashes in the plugin path - two are needed instead of just one).  When I reviewed its functionality as compared to the original script off of the CD, the changes do not appear to really have an effect on how it behaves (other than it not being able to find the plug-in for the reason described above).

           

          I have attached the default script from the CD, and recommend that you...

          1. Insert it into your system as a new script
          2. Find the bank assigned to the release station you will be testing with
          3. Assign the newly created script to the billing event of the bank found in step 2
          4. Issue a Change Control
          5. Update the Card ID field of your account to have your CS Gold card number
          6. Try again...

           

          If this doesn't work, you might want to start with verifying that the system has the basic configuration in place.  Presuming this has worked in the past, your CS Gold server address and port should be correct, but you may need to make sure that the service is started and/or that the billplug is pointed to the server on which the Pharos end of the CS Gold gateway resides (the bill plug and CS Gold gateway are commonly installed together, but you may have a single gateway and multiple billplugs on other servers pointed back to a single Pharos CS Gold gateway).  There should be a batch file in the same folder as the billplug executable for testing against CS Gold, though you will likely need to modify it unless it has already been set up for doing a test before.

           

          If UAC is enabled on your server, you will likely need to run that plugin as an administrator from the command line so that it has permissions to write the output file.  Alternatively, you can update the paths in the file to be full (be sure to wrap paths with spaces in double quotes), as when you right click on a batch file and run it as administrator, it will not start in the same path from which it was launched and you will get an error that billplug cannot be found.  I also usually add a PAUSE at the end of mine so that you can see what is onscreen.

           

          On an unrelated note, I met Richard Smith Jr at the Pharos conference.  Do you happen to know him?

           

          Regards,

          Steven

          1 of 1 people found this helpful
            • Re: Scripting Help..Card Swipe Logon
              Mark Elmore Adventurer

              Steven,

               

              Thank you for your help. The billing portion we didn't change much other than specifying the plug-in path. I made the recommended changes which does work. However, I was wondering if there is a way to make the billing script use the raw card data direct from the card swipe. We do not have the card id field populated for our users, so being able to bypass having to have that field is ideal. Yes, I do know Richard Smith, he is my manager. I was with him at the Pharos conference this year although I don't think I had the opportunity to meet you.

                • Re: Scripting Help..Card Swipe Logon
                  Steven English Guide

                  Mark,

                   

                  I do not have time to look into it in more depth right now, but at first glance it looks like the card ID that is sent to the gateway starts out as the actual string that is swiped.  During the process of retrieving the user's balance from Pharos, you will see that the card ID is overwritten with whatever is in the user record's Card ID field (Line 183).

                   

                  You could change this to a different field if needed (e.g., "user""card_id" if you want the Logon ID to be sent to the gateway) or you could just comment it out, and I expect that everything on the card stripe will be sent to the billplug.  You can use the regular expressions in the card type definitions of the gateway to eliminate characters which you are probably already doing to eliminate the starting and ending sentinels.  Remember the change control, and to restart the gateway service if you make any changes there.

                   

                  Line 183 Commented Out:

                  // sPharosCardId = User.GetProperty("card_id");

                   

                  Brief comment on the plugin path... If possible, I recommend leaving the script definitions as is so that it will not be hardcoded to a path but will look for the plugin in a folder relative to wherever you have decided to install Pharos.  This is especially beneficial if you have multiple server platforms, multiple install paths, or even if you migrate at some point and install it to a different path or drive.

                   

                  Regards,

                  Steven

                  1 of 1 people found this helpful
                    • Re: Scripting Help..Card Swipe Logon
                      Mark Elmore Adventurer

                      So, tired commenting sPharosCardId out and it did not pass the card data. If the card id field is filled in, everything seems to work. If it's not filled in it doesn't return a balance. We do not have the option of being able to fill the card id field in since we support guests as well as students and staff/faculty. I think our problem is with the logon side as that seems to be the part that is not passing on any information. In our current configuration, we require our users to input their university id or the guest account for those who are guests, after they enter that they swipe their card for billing. This works just fine. Tested the billing script using only the billing script and requiring manual input of id also followed by swiping. This also works just fine. I know this is a weird situation..I am open to any ideas on how to get the system to pass the raw card input from the logon script. I have tried adding other variables to hold the raw card data but that has not worked so far. I know the system will pass the raw card information if there is no card id field filled in, this happens with the our current configuration and the configuration I tested.

                        • Re: Scripting Help..Card Swipe Logon
                          Jason Pelletier Tracker

                          We did something similar but did have their cardID somewhere in Pharos. We didn't need to use CardID field because we didn't (and don't yet) have a need for students to login manually. Their cardID is their login, with no password. It wasn't until using MobilePrint that we needed the logonID to be their usernames. We had their card numbers as their logonIDs. Do you have their card numbers in Pharos at all? Do your guests get cards to swipe and release as well and if so, are they tied to CSGold (ours are)?

                           

                          It does not look like the billing script can use plugin.username which is what the login script uses to capture the card data but perhaps you can get fancy. Output the plugin.username to a text file and maybe pull that back in (might get tricky if there's high volumes of printing since files could get confused) or even call a SQL query to actually add the cardID into the CardID field on swipe? We do something similar but not exact as we increment student's card ID number by 1 if they have them re-issued but we need to be able to do this on the fly. Our query looks like this: DB.SQL("update users set user_alias = '"+uname+"', card_id = '"+uname+"', active = 1 where user_id = (SELECT Max(user_id) FROM users WHERE card_id LIKE '" + smalluname + "%')"); A little more complex than you'd need it since we have some other things going on with lost card counts and card id numbers but it might work for you.

                          1 of 1 people found this helpful
                  • Re: Scripting Help..Card Swipe Logon
                    Willis Dair Tracker

                    A few things to be aware of here-

                    -The login event and the billing event are separate things, so something happening in the login event does not pass anything to the billing event, other than the Pharos username. The login event is just a yea or nay event.  You either return a true or false value to allow or disallow the login.

                     

                    -The default billing script called Billing - Pharos Accounts Plus Online Accounts.txt, debits funds from the internal Pharos database first and then from the external bill gateway. A quick scan of the code show that it will check the external gateway if there is a card value in Card ID Pharos database field.  That is probably why it worked when you entered a Card ID value.

                     

                    I haven't looked at your scripts in depth either, but I think you will either have to write something in the Card ID field to trigger the default Pharos billing script, or modify the Pharos billing script to do an external gateway call based on a username parse.

                     

                    You said something about not populating the Card ID because there are faculty/staff and guest users. Here are a couple of questions:  1) do the faculty/staff/guest accounts follow the same card number scheme? (where you parse out some part of the CS Gold account from the card)  2) do you prompt for a password each time they scan?

                     

                    One possibility that pops in my mind is to write the card information into the Pharos database Card ID field at login time, or you can check to see if an existing Card ID matches the one that is scanned and update it.  You know the username and if you ask for a password you can see if the person swiping the card is attached to the CS Gold account number on the card.

                     

                    I kind of recall you were using the Pharos Station as a release station.  When you scan the card at the Pharos station, (which behaved differently than an Omega or iMFP), the raw card data is sent to the login event.  If you want the Pharos username returned, you have to set it in the return value.  I played with doing an Omega-ess login on a Pharos Station and had to modify the script to return the username as well as return the true value.

                     

                     

                    Willis Dair

                    1 of 1 people found this helpful
                      • Re: Scripting Help..Card Swipe Logon
                        Mark Elmore Adventurer

                        Willis,

                         

                        Thank you for your suggestions. We have gone to using both a billing script and a logon script. Our faculty and staff accounts follow the same scheme however our guest account is literally 'guest'. We do have a logon script that now does everything we need it to do. We are looking at adding in users with one of the scripts if they do not exist in the database. Currently we are doing this through the logon script however it does not establish any of the properties we are wanting to set with. I wonder if we will have to use the billing script to set those properties. I will have a follow up post with the current versions of the script for review and feedback.

                          • Re: Scripting Help..Card Swipe Logon
                            Jason Pelletier Tracker

                            What properties do you want to set? As I mentioned before, we have to incremement a student's cardID number when they lose their ID card and we use the logon script to ensure that we're changing the Alias on the fly using a quick DB.SQL query. Something like this: DB.SQL("update users set card_id = '"+uname+"', active = 1 WHERE card_id LIKE '" + smalluname + "%" "'");

                            1 of 1 people found this helpful
                              • Re: Scripting Help..Card Swipe Logon
                                Mark Elmore Adventurer

                                Jason,

                                 

                                These are the properties we are wanting to set:

                                 

                                User.SetProperty("active",1);
                                User.SetProperty("billing_option","advanced");
                                User.SetProperty("access_level","User");
                                User.SetProperty("offline_limit",5);
                                User.SetProperty("offline_amount",5);   
                                User.SetProperty("group","uniprintusers");

                                 

                                We are using User.Insert() along with the variable for our ids. Currently it only sets active, billing option, and access level.

                                  • Re: Scripting Help..Card Swipe Logon
                                    Jason Pelletier Tracker

                                    Not an expert however I wonder if, after you insert the account you can check to make sure it exists and then set the items you're looking for. Something like this

                                     

                                    new strSQL = "SELECT * FROM users WHERE card_id LIKE '" + smalluname + "%'";

                                    DB.SQL(strSQL);

                                    if (DB.GetRow())

                                    {

                                       // Check for an exact match.

                                       DB.SQL("SELECT * FROM users WHERE card_id = '" + uname + "'");

                                       if(DB.GetRow())

                                       {

                                       IO.PrintLine("The account exists no need to update");

                                       PlugIn.Result = true;

                                       PlugIn.UserName = DB.ColumnByName("id");

                                       IO.PrintLine("plugin.UserName = " + PlugIn.UserName);

                                     

                                       exit

                                       }

                                       else

                                       {

                                       IO.PrintLine("Account exists but need to update the issue number");

                                       IO.PrintLine("Setting options for new card");

                                       DB.SQL("update users set card_id = '"+uname+"', active = 1 , billing_option = "advanced", access_level = "user", offline_limit = 5, offlin_amount = 5, group = ?? WHERE card_id LIKE '" + smalluname + "%'");

                                       PlugIn.Result = true;

                                       PlugIn.UserName = DB.ColumnByName("id");

                                       exit

                                       }

                                    The trick is that group is a group number so that one could get a bit tricky having to look the number up to match the name, unless you stick to a few groups and then could hardcode the number.

                                     

                                    This might not work exactly and you'll need to find out how to verify if the card is new or not (perhaps key off some of the data. If one of the fields is blank then the card is probably new) but with some work, it might be an option for you.

                                    1 of 1 people found this helpful
                            • Re: Scripting Help..Card Swipe Logon
                              Mark Elmore Adventurer

                              I want to thank every one who posted to this thread and also my other initial thread for all of your input and advise. We have a fully functioning script that does what we want it to do as far as logging in our users and preserving our guest accounts. We do not have it adding users since I can not find a way to have it set the various properties that we want to set within the script.