Hello everyone,
My application runs under low privilege account like NetWork Service, but in some specific method I need to have high privilege (e.g. to write to registry or access some local file).
So, I want to change the user privilege of some specific method of a class. Does anyone have any good ideas how to do this in .Net?
I have investigated impersonate technologies and it looks good. But two more issues with impersonate technogies.
http://www.codeproject.com/KB/cs/zetaimpersonator.aspx
- How to manage the password expire issue? (for example, in the current domain, the policy is for every 6 months, password must be changed);
- Is it possible to impersonate from a high privilege to a low privilege user without providing password? My concern is to hardcode password in source code.
thanks in advance,
George

Bechir BejaouiRank #144 · 15.9K reputationPosted Nov 4, 2008, 1:59 PM EST
George GeorgeRank #1,736 · 870 reputationPosted Nov 4, 2008, 7:53 PM EST
Hi Bechir,
I am confused why I need to check web.config? My confusion is web.config controls the behevior and configurations for the whole web site. I just want to impersonate in a special method (to access some storage). I think I need to write code to impersonate in the special method I want to make impersonate happen, not from the web.config to impact the whole web application.
Any comments?
regards,
George
Bechir BejaouiRank #144 · 15.9K reputationPosted Nov 13, 2008, 12:40 PM EST
it could be possible that the administrator stocks some info about password and id because you can't impersonate a user without knowing its password and id except that he lives without loggig out so you can snoof it
George GeorgeRank #1,736 · 870 reputationPosted Nov 16, 2008, 3:12 AM EST
Thanks Bechir,
1.
Let me clarify and confirm your points. You point is to impersonate we do need the password of the account which we will impersonate to? And your solution is to store password into configuration file?
2.
I am wondering which attribute of configuration file (app.config?) is reserved to store password?
3.
Store password in clear text in configuration file (I have this confusion because app.config is clear text file)??
regards,
George
Ryan AlfordRank #1,411 · 1.2K reputationPosted Nov 16, 2008, 6:11 AM EST
Think of the security concerns of Microsoft allowing a code set to be able to run with admin privileges even though the current user doesn't have those privileges. Viruses would be even worse than they are now.
George GeorgeRank #1,736 · 870 reputationPosted Nov 17, 2008, 2:19 AM EST
Thanks Ryan! The purpose I want to have is to make the application not be able to access some folder, except call the method in a DLL which helps the application to access the folder, and it is why I want to impersonate in the specific DLL function. Any comments or ideas to achive this?
regards,
George