Shared path access failed with error: (6, 'DuplicateToken', 'The handle is invalid.')

jaril nambiar 51 Reputation points
2021-10-26T10:08:15.637+00:00

One of my applications is trying to access a shared path of Windows Server using a local user. Intermittently failed to access shared path.

Observed the below entries in the log.
in setup_share_access
in begin_impersonation
error: (6, 'DuplicateToken', 'The handle is invalid.')

Application installed on a Windows Server 2019 Standard
The application is in the latest version
Shared path: \192.168.0.10\backups$\1S0V1R0
User : bkpadmin

Installed Windows patches on the above server are
KB4512577
KB4577667
KB4587735
KB4535680
KB4598480
KB4601393
KB5001404
KB4577586
KB4589208
KB5003243
KB5003711
KB4486153
KB5005112
KB5005701
KB5006672
KB5005540

Can someone help me to understand the reason behind this error?
When did it occur?
How to prevent this?

Windows for business Windows Client for IT Pros Networking Network connectivity and file sharing
Windows for business Windows Server User experience Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Gary Reynolds 9,621 Reputation points
    2021-11-03T08:45:12.227+00:00

    Hi @jaril nambiar

    Are you able to provide a bit more information on the functions that you used to impersonate the user and if you received any errors when this function was called, as the error has probably occurred on the previous call(s) that created the user token that you are try to duplicate?

    Gary

    0 comments No comments

  2. jaril nambiar 51 Reputation points
    2021-11-06T05:27:02.22+00:00

    Hello Gary,

    Thank you very much for your time and comment.

    I'm not aware of the function details. I got error 6 from the backup application log. The behavior is, whenever a backup triggers, it verifies the backup destination.

    A successfull backup log
    2021-10-25 08:45:00 I [14512] backuprun (51):
    2021-10-25 08:45:00 I [14512] backuprun (52): ----- backup start -----
    2021-10-25 08:45:00 D [14512] stcapi (158): stc_create_session
    2021-10-25 08:45:00 I [14512] backuprun (86): BackupJob(name=u'XXXXXX-Backup', uuid=u'c8ea9032df6b424882a8aa4abd7fc7cd')
    2021-10-25 08:45:00 I [14512] backuprun (149): initial backup type: <BackupType.incremental: 2>
    2021-10-25 08:45:00 D [14512] backuprun (177): confirmed access to Destination(name=u'XXXX-XX', path=u'\\XXX.XX.0.91\backups$\XXXXXXX')

    A failed backup lo
    2021-10-25 09:45:00 E [7600] backuprun (106): backup error
    Traceback (most recent call last):
    File "D:\bamboo-home\xml-data\build-dir\SPX-CXSPX543-JOB1\spx_service\backup\backuprun.py", line 91, in run
    File "D:\bamboo-home\xml-data\build-dir\SPX-CXSPX543-JOB1\spx_service\backup\backuprun.py", line 174, in _setup_destination
    File "D:\bamboo-home\xml-data\build-dir\SPX-CXSPX543-JOB1\spx_service\database\models\destination.py", line 175, in setup_access
    File "D:\bamboo-home\xml-data\build-dir\SPX-CXSPX543-JOB1\stc_misc\xos\win32\box.py", line 107, in setup_share_access
    File "D:\bamboo-home\xml-data\build-dir\SPX-CXSPX543-JOB1\stc_misc\xos\win32\auth.py", line 34, in begin_impersonation
    error: (6, 'DuplicateToken', 'The handle is invalid.')


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.