Question

I have a virtual directory configured on my IIS server, pointing to a UNC network location - "\\esdata\userdata". When I set this up I set a specific user in IIS config, and I know this user has full permissions on this directory.

Now in my Web.API controller, I am looking for a specific subdirectory in that virtual directory- say johndoe (so \\esdata\userdata\johndoe). I can create my DirectoryInfo object okay, and the path it shows is exactly the right one. But if I call GetDirectories() on that directory info, I get an Access Denied exception- even though there are definitely subdirectories and even though the user IIS is using to access that directory has full rights.

So first, is this a limitation of GetDirectories()? I have read it has some issues. What can I do to work around this, or what am I doing wrong?

Was it helpful?

Solution

Found the problem and fixed it. Bottom line was that I had to configure the default ApplicationPool to use the identity of my authorized user, following the docs here.

I think what gave me trouble is that I had this directory mapped as a Virtual Directory in IIS, and mapped it as that same user. Apparently this doesn't give the permissions to access that info the way I thought it would. Probably not a great idea to change the application pool identity, but for an intranet based site it will get me where I want to go :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top