Tuesday, April 01, 2014

taking mifare card data and importing the UID into equitrac express

So this is not really going to appeal to many people as its kind of specific, but at my work we use MiFare cards to log onto our printers and print out work. The printers are Ricoh machines and we use their software (equitrac) to run the system and database.

We needed a way to automatically assign the UID number from the card to the user that it is assigned to in the equitrac database. I wrote the code in AutoIt because its awesome.

Here it is

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

; create GUI window
$Form1 = GUICreate("Test Gui", 269, 150, 193, 115)
;create two labels for the input boxes
GUICtrlCreateLabel("Card UID", 20, 16, 50, 21)
GUICtrlCreateLabel("Username", 20, 50, 50, 21)
; create two input controls
$Input1 = GUICtrlCreateInput("", 72, 16, 121, 21)
$Input2 = GUICtrlCreateInput("", 72, 50, 121, 21)
; create a button which says "press me"
$Button1 = GUICtrlCreateButton("Press Me", 96,80, 75, 25, 0)
; set the GUI to to show, so you can see it
GUISetState(@SW_SHOW)

While 1 ; loop until expression is false
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE ; if the user clicks on X (closes the window)
            Exit ;  the script will exit.
         Case $button1 ; the user clicks on the button
            $sString = GUICtrlRead($Input1);UID added to variable
            $username = GUICtrlRead($Input2);username added to variable
            $sString1 = StringStripWS($sString,8) ;remove spaces from UID
            $sReversed = StringRegExpReplace($sString1, "(.{2})(.{2})(.{2})(.{2})", "$4$3$2$1") ;rearrange the hex value
                   
                     Local $iDec = Dec($sReversed, 2) ;convert hex to decimal
                     Run(@comspec & ' /c "c:\program Files\equitrac\Express\Tools\eqcmd.exe" -sSERVERNAME modify ur '& $username &' ! ! ! ! '& $iDec) ;run the command prompt to add to equitrac
                   
                   
    EndSwitch
WEnd; end of loop


So after the include section you have the part that builds the GUI. Then comes the code. What it does is take the UID, move it around, convert into hex and then add it into the database. The only bit you'll need to change is the line after the 'run' command where i've put SERVERNAME. You put your database server name in there (there is NO space between the -s and the name) and that's that.

Hope this help someone!

Monday, March 18, 2013

Letting users change their expired passwords through RDP when connecting to a Hyper-V Windows 7 Client

We've had a problem at work where users could not log on when their passwords expired. These users are using thin clients (Microsoft Thin PC) and connecting to a server running Server 2008, with Hyper-V installed. Hyper-V is running Virtual PCs with Windows 7 professional as the OS. We require users to change their passwords once a year for security, but they were not even given the option to change their password. 

After many, many, many weeks of searching we did finally find an answer to this. Its a simple registry key that needs changing and for all you lovely people out there, here it is

The location is HKey Local Machine -> System -> CurrentControlSet -> Control -> TerminalServer -> WinStations -> RDP-TCP

The registry key which needs changing to get the VM’s to change expired password is SecurityLayer =0

This should be changed on the Virtual PCs themselves and not the thin clients.

Hope this helps people

Thursday, January 31, 2013

SOLVED - Group Policy Client Service Failed The Logon

We've had this problem at work a few times now. When someone comes to log onto a computer it gives them a message saying "Group Policy Client Service Failed The Log on". Goggling this gave a lot of answers but none of them seemed to solve it. In the end we resorted to re-imaging the computer as it only took an hour. Most of the answers from Google revolved around deleting the corrupt local profile and then getting them to log back on. This never worked for us for some reason.

In the end we discovered that it was a permissions problem and not a corrupt profile problem. This is how we solved it.

1) First log on to the computer with an administrators account.

2) First make sure that 'Hide protected operating system files' is unticked in folder options. Then load up regedit

3) Click on the 'Users' Hive and then click 'File' at the top and choose 'Load Hive'


4) Browse to the users folder on the C drive and then into the profile of the account you are having a problem with. In here you will see a file called 'ntuser.dat' open this.

5) It will ask you for a name. Give it any name, it doesn't matter what it is.

6) You will now see the hive you just loaded with the name you gave it under the users hive.

7) Right click on this hive and choose 'Permissions'

8) In here you should see three accounts. System, Administrators and the user name of the person who's profile you are fixing. If ANY of these are not shown it will not work. You need to add all three and then give them full control in the permissions section. There may also be a user called 'restricted'. you can add this if you want but it will work without it. In the picture below you will see that a username is not there. You will need to add it.


9) Once you have added all three and given them the correct permission you can close it and then close the registry.

10) Log off

11) Get the user to log on and they should be fine!