views:

113

answers:

1

I need to let an aspx.cs file run code to enumerate the contents of a directory on another server altogether. Basically, use a Directory object, etc.

Here is what I can piece together (I'm really not a network rights guy at all, so this is all confusing to me.) When a user loads my aspx page, that page, code behind, is actually running under some kind of windows user account. IUSR_ or something.

For some reason, the server I need to reach (it's a Page Flex server) will not let me change the "Location" to search for users in so I can't go find /IUSR... and give it rights.

Is there some way to pass credentials as I try to enumerate the contents of a remote server's directories?

I really hope that made sense.

+1  A: 

I don't know all your security constraints, but you may want to look into delegation

http://msdn.microsoft.com/en-us/library/aa291350%28VS.71%29.aspx

There's lots of other articles on it if you search google

EDIT:

From: http://msdn.microsoft.com/en-us/library/xh507fc5%28VS.71%29.aspx

<!-- Web.config file. -->
<identity impersonate="true" userName="contoso\Jane" password="pass"/>

The idea is to have the web request run as whatever domain user does have access to the share, instead of the default (IUSR_* or ASPNET user, I can't remember)

I believe you can do this for just a subdirectory or script if you want to limit what scripts are running as this user, see http://msdn.microsoft.com/en-us/library/b6x6shw7.aspx

<location path="ReadUNC.aspx">
    <system.web>
        <identity impersonate="true" userName="contoso\Jane" password="pass"/>
     </system.web>
</location>

And if you want to do the impersonation programmatically, maybe this will help get you started: http://www.west-wind.com/WebLog/posts/1572.aspx

jayrdub
Hmmmm. I was trying to figure out that article, but I'm not having any luck, because I'm not the smartest man. (Or maybe it's that I've put in 90 hours since Saturday and I can't see straight.) Thanks for the pointer, jayrdub. I'll try to revisit this with a clear mind after some sleep, whenever that will be.
Matt Dawdy
Okay, that seem ultra promising. I'm trying to get the code setup to test it. Thank you for following up, I just was NOT using the right search terms, I guess.
Matt Dawdy
jayrdub, I'm sorry I have'nt accepted your answer yet. I got the flu, and we haven't been able to try it out (this is all made more complicated as it only can be tested on a remote server and I personally don't have access to it right now.) After I get a chance to test it I'll come back.
Matt Dawdy