none
ImportNtmsDataBase fails with error ERROR_NO_TOKEN RRS feed

  • Question

  • Hi,
       When I try to import the RSM database, get the error  ERROR_NO_TOKEN (1008 - An attempt was made to reference a token that does not exist) for the function ImportNtmsDataBase. The same code works on Windows 2003.

    Have tried running as administrator, as a service. Get the same error on each occasion.
    Any help will be appreciated.

    Thanks
    Viswa
    Wednesday, December 3, 2008 6:02 AM

All replies

  • Hi Viswa,

    It would be helpful if you could provide more information on what the code is trying to achieve. Also, in what context and for what purpose the call to ImportNtmsDataBase is being made.

    Regards,
    Chaitanya
    Wednesday, December 3, 2008 9:20 PM
  • Thanks for your response.

    The code tries to restore the RSM database and the call was being made to restore the RSM database from the backed up copy.

    Sequence of code:
    1. get the backed up DB files and copy them to the export folder.
    2. Call OpenNtmsSessionW .
    3. Call ImportNtmsDataBase
    4. Call CloseNtmsSession
    Thursday, December 4, 2008 6:27 AM
  • Hi,

    You may be getting the error because the thread that calls ImportNtmsDatabase may not have the right token associated with it. This is an excerpt from the link
    How To Determine Whether a Thread Is Running in User Context of Local Administrator Account :

    "By default, the token that is associated with a thread is that of its containing process. This "user context" is superceded by any token that is attached directly to the thread."

    Hope this helps.

    Regards,
    Chaitanya
    Monday, December 8, 2008 7:12 PM
  • Thanks again for the response. I was not available for the last few days....

    Have seen the link and used the piece of code to verify if the process is running as admin. It is indeed running as admin.
    And the same error is returned by ImportNtmsdatabase.
    Wednesday, December 17, 2008 6:35 AM
  • Hi,

    To obtain a token for the thread the function
    OpenThreadToken() must be called. If this fails then the next function to try is OpenProcessToken(). This is what the link I had sent said.

    Since that is failing, you could try this.Forcibly obtain a token when OpenThreadToken() fails, call ImpersonateSelf().

    "The ImpersonateSelf function obtains an access token that impersonates the security context of the calling process. The token is assigned to the calling thread."

    Try it in this order:
    (pseudocode)

    if(OpenThreadToken() gives ERROR_NO_TOKEN) then
          ImpersonateSelf()
          OpenThreadToken()
    end if

    The second OpenThreadToken() call should definitely work.

    I would suggest that you post your query on the File Services and Storage forum for Windows Server 2008 as well.

    Hope this helps.

    Regards,
    Chaitanya
    Wednesday, December 17, 2008 6:32 PM
  • I have tried OpenProcessToken as well as ImpersonateLoggedOnUser.
    After ImpersonateSelf, the OpenThreadToken call succeeds.

    However, the ImportNtmsDataBase call still fails.

    if (OpenThreadToken gives ERROR_NO_TOKEN)

             ImpersonateSelf
             OpenThreadToken() - Succeeds
    OpenNtmsSession - Succeeds
    ImportNtmsDatabase - Fails with ERROR_NO_TOKEN
    Thursday, December 18, 2008 6:31 AM
  • Switched to VSS for backing-up RSM DB on Windows 2008. Thanks for the replies.
    Wednesday, May 20, 2009 9:58 AM