private void IdentifyCallback(PVOID IdentifyCallbackContext, HRESULT OperationStatus,
                                      WINBIO_UNIT_ID UnitId, WINBIO_IDENTITY Identity, WINBIO_BIOMETRIC_SUBTYPE SubFactor,
                                      WINBIO_REJECT_DETAIL RejectDetail)
        {
            switch (OperationStatus)
            {
            case S_OK:
            {
                var accountSid         = Identity.Value.AccountSid[0];
                var sid                = new SecurityIdentifier(accountSid.Data.ToArray(accountSid.Size), 0);
                IdentityReference user = sid.Translate(typeof(NTAccount));

                if (user != null)
                {
                    IdentifySuccess(this, new AuthenticationSuccessEventArgs(user, (WinBioFinger)(int)SubFactor));
                }
                else
                {
                    IdentifyFailed(this, new AuthenticationFailedEventArgs(WinBioError.NoAccount, WinBioRejectDetail.None));
                }

                break;
            }

            case WINBIO_E_UNKNOWN_ID:
            {
                IdentifyFailed(this, new AuthenticationFailedEventArgs(WinBioError.UnknownId, (WinBioRejectDetail)(int)RejectDetail));
                break;
            }

            case WINBIO_E_BAD_CAPTURE:
            {
                IdentifyFailed(this, new AuthenticationFailedEventArgs(WinBioError.BadCapture, (WinBioRejectDetail)(int)RejectDetail));
                break;
            }

            case WINBIO_E_CANCELED: break;

            default:
            {
                IdentifyFailed(this, new AuthenticationFailedEventArgs(WinBioError.Failed, (WinBioRejectDetail)(int)RejectDetail));
                break;
            }
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            IntPtr handleSession = IntPtr.Zero;
            uint   NativeResult  = 0;
            uint   UnitId        = 0;
            WINBIO_REJECT_DETAIL RejectDetail = 0;
            IntPtr Sample     = IntPtr.Zero;
            int    SampleSize = 0;

            Byte[]     sampleContent;
            WINBIO_BIR sampleBIR = new WINBIO_BIR();

            NativeResult = WinBio.Native.WinBioOpenSession(WINBIO_BIOMETRIC_TYPE.WINBIO_TYPE_FINGERPRINT, WINBIO_POOL_TYPE.WINBIO_POOL_SYSTEM, WINBIO_SESSION_FLAGS.WINBIO_FLAG_RAW,
                                                           IntPtr.Zero, 0, /*DatabaseID*/ 1, ref handleSession);

            if (NativeResult != 0)
            {
                //Error
                return;
            }
            NativeResult = WinBio.Native.WinBioCaptureSample(handleSession, WINBIO_BIR_PURPOSE.WINBIO_NO_PURPOSE_AVAILABLE, WINBIO_BIR_DATA_FLAGS.WINBIO_DATA_FLAG_RAW,
                                                             ref UnitId, ref Sample, ref SampleSize, ref RejectDetail);
            if (NativeResult == 0)
            {
                if (Sample != IntPtr.Zero)
                {
                    sampleBIR     = (WINBIO_BIR)Marshal.PtrToStructure(Sample, typeof(WINBIO_BIR));
                    sampleContent = new byte[sampleBIR.StandardDataBlock.Size];
                    Marshal.Copy(Sample + (int)sampleBIR.StandardDataBlock.Offset, sampleContent, 0, (int)sampleBIR.StandardDataBlock.Size);
                    string outstr = BitConverter.ToString(sampleContent);
                    Console.Write("Sample Content: " + outstr);
                    WinBio.Native.WinBioFree(Sample);
                }
            }

            if (handleSession != IntPtr.Zero)
            {
                WinBio.Native.WinBioCloseSession(handleSession);
                handleSession = IntPtr.Zero;
            }
        }
        private void IdentifyCallback(PVOID IdentifyCallbackContext, HRESULT OperationStatus, 
            WINBIO_UNIT_ID UnitId, WINBIO_IDENTITY Identity, WINBIO_BIOMETRIC_SUBTYPE SubFactor, 
            WINBIO_REJECT_DETAIL RejectDetail)
        {
            switch (OperationStatus)
            {
                case S_OK:
                {
                    var accountSid = Identity.Value.AccountSid[0];
                    var sid = new SecurityIdentifier(accountSid.Data.ToArray(accountSid.Size), 0);
                    IdentityReference user = sid.Translate(typeof(NTAccount));

                    if (user != null)
                        IdentifySuccess(this, new AuthenticationSuccessEventArgs(user, (WinBioFinger)(int)SubFactor));
                    else
                        IdentifyFailed(this, new AuthenticationFailedEventArgs(WinBioError.NoAccount, WinBioRejectDetail.None));

                    break;
                }

                case WINBIO_E_UNKNOWN_ID:
                {
                    IdentifyFailed(this, new AuthenticationFailedEventArgs(WinBioError.UnknownId, (WinBioRejectDetail)(int)RejectDetail));
                    break;
                }

                case WINBIO_E_BAD_CAPTURE:
                {
                    IdentifyFailed(this, new AuthenticationFailedEventArgs(WinBioError.BadCapture, (WinBioRejectDetail)(int)RejectDetail));
                    break;
                }

                case WINBIO_E_CANCELED: break;

                default:
                {
                    IdentifyFailed(this, new AuthenticationFailedEventArgs(WinBioError.Failed, (WinBioRejectDetail)(int)RejectDetail));
                    break;
                }
            }
        }
Example #4
0
 public static extern uint WinBioEnrollCapture(IntPtr SessionHandle, ref WINBIO_REJECT_DETAIL RejectDetail);
Example #5
0
 public static extern uint WinBioCaptureSample(IntPtr SessionHandle, WINBIO_BIR_PURPOSE purpose,
                                               WINBIO_BIR_DATA_FLAGS Flags, ref uint UnitId, ref WINBIO_BIR Sample, ref int SampleSize,
                                               ref WINBIO_REJECT_DETAIL RejectDetail);
Example #6
0
 public static extern uint WinBioVerify(IntPtr SessionHandle, WINBIO_IDENTITY Identity,
                                        WINBIO_BIOMETRIC_SENSOR_SUBTYPE SubFactor, ref uint UnitId, ref bool Match,
                                        ref WINBIO_REJECT_DETAIL RejectDetail);