开发者

How to access file with UNC path from asp.net

When I access file whith UNC file path from asp.net, I found the following problem. Logon failu开发者_如何学Cre: unknown user name or bad password. Pls help me.


The problem may not be with the UNC nature of the path you're trying to access, but with the security credentials. If, for example, you are running your asp.net application under the System account, then you won't be able to access network shares because System is a local account (not a domain account).

I suggest you check in inetmgr under which user your application pool is running (under the Identity tab). Try using a domain account that can access that share.

How to access file with UNC path from asp.net


The solution is held under the impersonation and delegation functionality of asp.net. There are certain constructs which provide a token based security scheme to call a file.copy operation for example with the target being a UNC location. You can check it here.


The account "in charge" when the file access request is issued simply must be lacking credentials to access the share / resource found at the UNC location.

You first need to determine which account is effectively used, as this may vary, and provide the relevant privileges. By default most programs, including .NET programs (to a lesser extent) will run in the security context of the account which launched the program, however this doesn't hold, in many situations, for example if the program is a service of sorts, or if it uses some DCOM objects, or if it impersonate some other accounts etc... Also .NET has a relatively sophisticated system of delegation/impersonation.

One way to diagnose this issue is to add auditing at the level of the UNC file/directory. Upon failure this will leave a event which should show the login name of the account which tried to access the share.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜