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?