0

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...

KR.
  • 13
  • 3
  • Couldn't you move this system.web section into your SystemAdmin folder? Alternatively it would make sense to utilise DS authentication and ensure that the admin users have access to the network share. – Lazarus Feb 25 '10 at 13:24
  • Yes, but that wouldn't solve the problem. Then I would still need to use impersonation in the main web.config to make sure the control works in the non-admin pages (it is on every page since it is in the master page) – KR. Feb 25 '10 at 16:26

4 Answers4

0

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.

user171523
  • 4,185
  • 3
  • 35
  • 50
0

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

remi bourgarel
  • 9,231
  • 4
  • 40
  • 73
0

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:

File.Exists returning false from a network share

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

Community
  • 1
  • 1
KR.
  • 13
  • 3
0

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
  • 3,608
  • 3
  • 28
  • 39
  • 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. Feb 26 '10 at 10:18