LogonUser and delegation

前端 未结 2 1210
情歌与酒
情歌与酒 2020-12-11 07:34

I\'m using the LogonUser win32 api:

token = LogonUser(...)
WindowsIdentity newId = new WindowsIdentity(token);            
WindowsImpersonationContext impers         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-11 08:09

    after this I'm not able to use the impersonated identity

    The impersonation should be effective for access on the same box, but not on the network.

    It may be, as consultutah's code shows, that you just need to call DuplicateToken() in order to convert the logon token to an impersonation token before it can be used.

    I think this is because impersonatedUser.ImpersonationLevel equals Impersonation.

    If you need to act as the impersonated user to other systems, you need a higher level of impersonation called 'delegation'. This is basically equivalent to having the user's password so you can represent yourself as them to others.

提交回复
热议问题