开发者

Access to the path denied, trying to access remote server file

I'm havi开发者_如何学Pythonng a hard time trying to access a remote server file from other server with my asp .Net application (C#) hosted in it. The scenario is the following:

I wrote an MVC web application that is hosted on SERVER A; and in some instance, it has to let the user modify a XML configuration file that is located on SERVER B. So, here is the part of the code where I try to read that file from a shared folder on SERVER B:

(C# - Controller)

WindowsImpersonationContext impContext = null;
        try
        {
            impContext = NetworkSecurity.ImpersonateUser(
                Settings.Default.ImpersonationDomain,
                Settings.Default.ImpersonationUser,
                Settings.Default.ImpersonationPass,
                LogonType.LOGON32_LOGON_NETWORK,
                LogonProvider.LOGON32_PROVIDER_DEFAULT);
        }
        catch (ApplicationException ex)
        {
            // write to log file

        }
        if (null != impContext)
        {
            try
            {
                //get the location of the configuration file
                string remoteConfigFile = Settings.Default.RemoteDesktopMonitorCnfgFile;

                //open the configuration file
                XDocument xmlFile = XDocument.Load(@"\\SERVERB\Folder\configurationFile.exe.config");

So, my exception is here, when I try to open that configuration file, I'm getting the exception:

Access to the path '\\SERVERB\Folder\configurationFile.exe.config' is denied

As you could see, I'm impersonating the user before I try to read the file, that impersonation is well done; and I already gave full access to the shared resource to the user that I'm impersonating with. I even tryied joining that user to the Administrators group on both Servers (A and B) and the same exception occurs.

Maybe worth to say that both Servers are on the same Windows Domain, and that I'm using a user account that exists on the domain and that the password is correct.

Any help you could give me would be appreciate.

Thanks in advance.


There is a solution to your problem already on StackOverFlow

Check it out!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜