在asp.net中的模拟 [英] ImPersonation In asp.net
问题描述
嗨盖兹,
我试图从网络中的系统获取性能计数器的详细信息.
该项目在Web(ASP.NET)上,当前在本地主机上.
为了获取详细信息,我在vc ++中创建了一个dll.
在该DLL中,
我将代码称为模拟用户.获取计数器数据后,我致电REVERTOSELF结束模拟.
模仿用户:
我调用了以下函数:
1.LogonUser:以新用户身份登录
2.DuplicateTokenEx:具有安全功能的重复令牌.
3.ImpersonateLoggedOnUser:模拟用户
然后,我校准PdhConnectMachine以获得与指定用户的连接.
然后我将PdhEnumObjects校准2次.
首先分配mennory来保存绩效对象
其次获得所有性能对象列表.
然后我将ReverttoSelf设置为结束模拟.
我的问题是,在Revertself之后,我通过使用GetUserName Api获取当前用户名.
我得到了不同的用户名(预期用户名:SUMITH).即,Web文件夹的名称,或者有时得到IUSER $
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++ .
In that DLL ,
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 , Name OF Web Folder or sometimes Get IUSER$
.
Working in Local Machine Gets Exact OutPut. On Web it was not Working?
我不知道是什么问题?请帮助SomeOne?
I cannot Recognise what problem is ? Please Help SomeOne?
推荐答案
.
Working in Local Machine Gets Exact OutPut. On Web it was not Working?
我不知道是什么问题?请帮助某人?
I cannot Recognise what problem is ? Please Help SomeOne?
您可以使用CoInitializeSecurity
函数将模拟级别指定为RPC_C_IMP_LEVEL_IMPERSONATE
.
使用此msdn链接作为参考 http://msdn.microsoft.com/zh-cn/library/ms693736%28v = vs.85%29.aspx [
You can useCoInitializeSecurity
function specifying the impersonate level asRPC_C_IMP_LEVEL_IMPERSONATE
.
Use this msdn link for reference http://msdn.microsoft.com/en-us/library/ms693736%28v=vs.85%29.aspx[^]
这篇关于在asp.net中的模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!