PDA

View Full Version : Smart Card data read



leeweaver
06-25-2008, 02:33 PM
I am working on an access/VBA project that I need to identify who is using the application, and give different options and abilities to them based on that information. I also need to tag all entries they make with an identifier that they made them.

I have found enough information on the ?Net? that tells me I can do it, but no code examples.

The only thing I need from the Smart card is the User Name, but any other information any of you may have would be greatly appreciated.

Code examples and or links to a list of commands and/or Variables would be a life saver.

Feel free to contact me directly or on here.

Lee.weaver.ctr@swfpac.navy.mil
:banghead:

CreganTur
06-26-2008, 07:33 AM
Something we need to know is how the smart card is used in relationship to your databse.

Do users use the Smart Card to login to a PC (instead of a username and password),do they use the smartcard to login to the database, do they swipe it every time the make an entry, etc.?

Knowing this gives us a better idea of where to look.

leeweaver
06-26-2008, 07:52 AM
The smart card is for login. but a PIN is also entered

The reader is a GemPC usb SL.

The card is an Oberthur ID One V5.2

CreganTur
06-26-2008, 08:22 AM
The smart card is for login

I'm going to assume that you mean logging in to the PC.

If this is the case, then the username of the person logged onto the PC would be derrived from the smart card in some way. Since this is true, you could simply capture the name of the currently logged-on user, and use that to set your permissions.

This code grabs the current username. Just C&P it into a new module:
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
Environ$ ("Username")
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function

This will get you the username you're looking for. One way of getting the data is to assign the value of the above function to a variable. Which could look like:

Dim strUser As String

strUser = fOSUserName()

HTH:thumb

leeweaver
06-30-2008, 08:37 AM
Randy:

Thank you for your help.

I am still trying to access the smart card. Although this gives me a "username" it does not access the smart card directly, and I need information from it to do the digital signature needed to track changes.

Yes this would tell me who made the changes. But it isn't quite as definitive as a digital signature would be.

Lee

CreganTur
06-30-2008, 09:03 AM
does not access the smart card directly

I'm sorry to say that I have no idea how to query the smart card directly.

I was thinking that you just needed the Username, which is why I suggested snagging the name of whoever is currently the active user.

Hopefully someone else here has some experience in this area, and can help you figure out how to read the smart card.

CreganTur
06-30-2008, 01:49 PM
I decided to do a little more digging into this subject and found something that might help you.

Take a look at this: http://www.downloadjunction.com/product/store/22797/index.html

This will add an Active-X control that will allow you to work with smart cards. I haven't looked at it much past reading the description, but it sounds like what you're looking for.

God Speed:thumb

leeweaver
06-30-2008, 02:17 PM
Randy:

Thank you for this information. I will have to wait until I get home this evening to check this out. Our IT has this site blacklisted.

leeweaver
07-01-2008, 07:39 AM
Unfortunately this solution will not work. I am not allowed to install software. This must be installed. I was hoping for a VBA solution.

Thanks again Randy. I will attempt to find the answer on another forum.

CreganTur
07-01-2008, 07:57 AM
I was hoping for a VBA solution
This is a VBA solution, or at least a route to a VBA solution.
The reason I say this is because it installs an Active-X object library that you can utilize through Access. Referencing objects is how VBA interacts with other programs, and without a library that points to your smart-card reader, I imagine that it would be very difficult to find a work around.

Have you talked to any of your IT people, especially the people who install the smart-card readers? They may know if there is an object library already installed on your computer that you could reference, or how to get permission to have the library installed.


I will attempt to find the answer on another forum.
Good luck, hope you can find your solution quickly!