0

I have searched through web and tried all possible solution but my web app failed every time ! I have bunch of shared drive paths which I want to access through Web app. I have credentials to access this shared drive paths. The possible solution I found was enable identity impersonate but my web app is failing me in that case. I tried accessing it Using UNC API but that is failing too. I have been told that I can access this shared drives as directory service (dont need to use UNC API). Share your thoughts if you have any ! Thank you!

Enable Identity Impersonate

In Web.Config

<identity impersonate="true" userName="username" password="pass">

and it is not able to locate my project when I am enabling identity impersonate --Gives System.IO.DirectoryNotFoundException

(tried changing authentication mode(Windows,None,etc) in web.config -- same above error)

UNC Access

I took a copy of UNCAccessWithCredentials from here

https://www.codeproject.com/Articles/43091/Connect-to-a-UNC-Path-with-Credentials

using (UNCAccessWithCredentials unc = new UNCAccessWithCredentials()) 
//access network drives through functional id 
{ 

try
{
if (unc.NetUseWithCredentials(sharedrive, functionalID, domainName, 
functionalPass))
{ 
string[] files = Directory.GetFiles(sharedrive);
}
}
}

It throws error 87 inside NetUseWithCredentials() method

11
  • When I see something like this, my first question is: why do you need to access an internal remote network location from your web application? You're opening yourself up to performance issues and failures that are difficult to debug. Commented Aug 10, 2017 at 14:05
  • You can use the FileWebRequest from System.net namespace and DirectoryInfo class read it. I haven't tried it but it should work. Commented Aug 10, 2017 at 14:09
  • DirectoryInfo class to get the information on network drive. Commented Aug 10, 2017 at 14:15
  • So, what do you mean "failing me", what error message(s) do you get? If you post your code someone may be better able to help you. Commented Aug 10, 2017 at 15:22
  • @ Joshua Drake -It is not able to find the path of an application upon enabling identity impersonate ---- System.IO.DirectoryNotFoundException Commented Aug 10, 2017 at 15:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.