Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guyz,


i tried to get performance counters details from system in a network.

this project is on web(ASP.NET ), Currently on local host.

To get the conters details , i created a dll in vc++ .


I call Code to Imersonte User .After Getting Counters data, i Called REVERTOSELF to end impersonation.

To Imersonate User :

I called the following Functions :

1.LogonUser : to logon as New user

2.DuplicateTokenEx : Duplicate The token with security features .

3.ImpersonateLoggedOnUser : To impersonate the user


Then I cal PdhConnectMachine To get Connect with specifed User.

Then I cal PdhEnumObjects 2 time .

first to allocate mennory to hold the performance object

second to get all Performance object list.



then i cal ReverttoSelf to end impersonation.



MY problem is that , the After the Revertself i get current user name by using
GetUserName Api.

i got different username (expected Username : SUMITH).ie ,

The user before impersonation : Sumith

The user After impersonation : Admin

when unimpersonate (calling reverttoself) the user : Local Service




i used the CoInitializeSecurity () . But the Result is same? What i do some one

give me a solution?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900