Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7580547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:56:41+00:00 2026-05-30T17:56:41+00:00

I already asked about how to get the user name. How can I get

  • 0

I already asked about how to get the user name.
How can I get the user name who invoked the method of COM server?
Now I need to get the SID too. How do I do this?

The OpenProcessToken approach doesn’t work because this function fails with ERROR_BAD_IMPERSONATION_LEVEL error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:56:43+00:00Added an answer on May 30, 2026 at 5:56 pm

    UPDATE
    In order to do this, the client should allow the server to get its information by configuring the proxy with CoSetProxyBlanket API as shown below:

    HRESULT hr;
    if(FAILED(hr = ::CoSetProxyBlanket(
                unk // An interface the client uses to access the com server
                , RPC_C_AUTHN_DEFAULT
                , RPC_C_AUTHZ_DEFAULT
                , NULL
                , RPC_C_AUTHN_LEVEL_DEFAULT
                , RPC_C_IMP_LEVEL_DELEGATE // This flag should be *_DELEGATE or *_IMPERSONATE or *_IDENTIFY
                , NULL
                , EOAC_DYNAMIC_CLOAKING)))
        throw com_exception(hr, "Failed to set proxy blanket");
    

    Then being impersonated (CoImpersonateClient) you may access the user’s token with OpenThreadToken.

    END OF UPDATE

    And after that you may use GetTokenInformation API as follows:

    DWORD tokenSize = 0;
    ::GetTokenInformation(token, TokenUser, NULL, 0, &tokenSize);
    
    ....
    TOKEN_USER *tokenInfo; // should point to a memory location of size tokenSize.
    ....
    if(::GetTokenInformation(token, infoClass, tokenInfo, tokenSize, &tokenSize) == FALSE)
        throw win32_exception(::GetLastError(), "Failed to obtain token information");
    

    tokenInfo will contain the field User.Sid of type PSID.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've already asked this question, but that was about FreeImage . Now I'm trying
I already asked a question about this yesterday, but now I have another :)
Somebody already asked how you can get git to follow symlinks. There was an
I've actually asked about this already in this post although we've gone back to
Apologies if this was already asked but, I have had a look and can't
THIS USER HAS ALREADY ASKED THE EXACT DUPLICATE A FEW MINUTES AGO sql and
I am generating log records about user actions. For privacy reasons, these need to
There are already so many questions asked about this already. One popular answer is
I have already asked some questions about this topic, I have made some modifications
I already asked this question but I didn't get my answer. Btw I found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.