views:

38

answers:

4

The masterpage of my site is using a control that reads data from a network share. To make this work on all pages I'm having to enable impersonation for the whole site. But what I want to do is only enable it for the pages that actually read/write to the share. Eg:

    <location path="SystemAdmin">
    <system.web>
  <identity impersonate="true" password="abcdefgh" userName="MYDOMAIN\Administrator" />
  <authorization>
    <allow roles="Admin" />
    <deny users="*" />
  </authorization>
</system.web></location>

If I do this, my masterpage control only works on the admin pages. Kinda stumped here...

A: 

U can impersonate using c# code on code behind or u can write service n call that. If it is not real time U can put in local store r cach.

A: 

Or you can use a location only for a specifi page :

remi bourgarel
A: 

Ok,

So I used a custom class to impersonate the Administrator only while the master page code-behind is reading data from the network share. See:

http://stackoverflow.com/questions/401284/file-exists-returning-false-from-a-network-share#401325

I'm happy with this solution, but if anyone has any genius solutions I'd be happy to hear them. I'm unhappy with storing the administrator password in web.config; So maybe someone has a solution for that too?

Thanks

KR
A: 

On a simpler note. Why dont you use two master pages. One with that functionality and the other without. This way you can use the master page which required impersonations in specific pages and the other one which does not need to get information from the shared resource.

Hope this helps.

Thanks, Raja

Raja
All my pages need to get information from the shared resource, that's why I don't want to put impersonation on the public pages.
KR