none
Windows Biometric Framework: AcquireFocus() not wokring. Error AccessDenied : 0x80070005 RRS feed

  • Question

  • I am developing a windows service to capture fingerprint sample. WBF (Windows Bio metric Framework) requires focus to capture sample image, for which i am using AcquireFocus().

    Exporting from DLL is as follows.

     class Focus
        {
            protected const string LibName = "winbio.dll";

            [DllImport(LibName, EntryPoint = "WinBioAcquireFocus")]
            public static extern WinBioErrorCode WinBioAcquireFocus();

            [DllImport(LibName, EntryPoint = "WinBioReleaseFocus")]
            public static extern WinBioErrorCode WinBioReleaseFocus();
        }
    Usage is as follows

    WriteToFile(DateTime.Now + " Acquiring Focus" + "\n");
    re = Focus.WinBioAcquireFocus();
    if (re.Equals(WinBioErrorCode.Ok)){
        WriteToFile(DateTime.Now + " Calling CaptureSample Image." + "\n");
        result = wbf.CaptureSampleImage();
     }
     else{
         WriteToFile(DateTime.Now + " Error in Acquiring Focus: " + re + "\n");
      }
    This function requires the process to be running on LocalSystem account as mentioned in documnetation. I have set this in service settings.

    this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
    CaptureSampleImage() is defined in a DLL. Now i am always getting error 0x80070005 which is Access denied. Log file is as follows.

    10/22/2019 4:16:06 PM Acquiring Focus
    10/22/2019 4:16:06 PM Error in Acquiring Focus: AccessDenied
    10/22/2019 4:16:06 PM Stopping Service.

    Error codes are defined as Enum as follows
        public enum WinBioErrorCode
             : uint
        {
            Ok = 0,
            False = 1,
            AccessDenied = 0x80070005,
            ...
        }
    The documnetation says that this arises due to service not being on LocalSystem, whereas it is.
    For logging purposes, i have written writeToFile(message), that write message to .txt file.
    What can i do to remove this error?
    Thanks in advance.


    Tuesday, October 22, 2019 12:55 PM

All replies

  • Hi,

    Have you enable the biometrics on you Device?

    Turn on the Biometric in Control Panel > Hardware andSound > Biometric Devices. 

    Make sure you enable the following Group Policy:

    Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > Biometrics:

    Allow the user of biometrics

    Allow users to log on using biometrics

    Allow domain users to log on using biometrics

    Best Regards,

    Drake


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, October 23, 2019 3:40 AM
    Moderator
  • Hi Drake. 

    The Biometrics are working fine. I have used winbio.h in normal c# Application and its working just fine. 

    The problem arises when i try using it in a windows service for which i have to use AcquireFocus().

    PS: I have done the steps youmentioned, its not working.

    Thanks and Regards.

    Wednesday, October 23, 2019 5:18 AM
  • Did you try uninstalling and reinstalling the service?
    Wednesday, October 23, 2019 9:49 AM
  • Hi Awais,

    After communication with relevant internal engineers, they suggest to change the identity to your user ID and password as follows.

    1. Go to the services
    2. Select the service custom service which creating the issue now
    3. Right click and go to properties
    4. Select the logon tab
    5. Select the radio button this account
    6. By clicking the browse button , you can see the option to enter the specific user name and find then select hit ok
    7. Give the password
    8. And hit ok
    9. Finally restart the service

    and please let us know what’s the out come, still you're facing the access denied error or not?

    Best Regards,

    Drake


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 22, 2019 2:57 AM
    Moderator