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