访问路径“*****”被拒绝

发布于 2024-12-20 17:26:11 字数 451 浏览 1 评论 0原文

我在同一网络中有一个文件夹“\lo1dc\abcd\Admin\Images”,我为每个人设置了完全权限。我在同一网络内的另一台计算机上创建了一个新的 Web 应用程序,并创建了一个名为“_images”的虚拟目录并设置了此文件夹路径。我在创建帐户时将路径凭据设置为指定用户,并将名称设置为管理员。这是整个网络的管理员用户。

现在,在尝试保存图像时,如下所示,

string strSaveLocationCode128 = Server.MapPath("~/_images") + "//abc.Jpg";
barcodeCode128Mobile.drawBarcode(strSaveLocationCode128);

这向我显示错误消息“访问路径 '\lo1dc\abcd\Admin\Images\abc.Jpg' 被拒绝”。

请帮助我,我使用 Win 7 作为我的开发平台。

I have a folder in my same network as "\lo1dc\abcd\Admin\Images" I set full permission for everyone. I created a new web application in another machine within the same network and created a virtual directory called "_images" and set this folder path. I have set the path credential as a specified user while creating account and set the name as administrator. Which is administrator user for entire network.

Now while trying to save image as shown below

string strSaveLocationCode128 = Server.MapPath("~/_images") + "//abc.Jpg";
barcodeCode128Mobile.drawBarcode(strSaveLocationCode128);

This is showing me the error message as "Access to the path '\lo1dc\abcd\Admin\Images\abc.Jpg' is denied".

Please help me I am using Win 7 as my development platform.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡墨 2024-12-27 17:26:11

最后我找到了答案,匿名用户无法访问网络路径。所以

SPSecurity.RunWithElevatedPrivileges

对我来说已经成功了。
感谢大家在适当的时候提供的宝贵帮助。

Finally i found out the answer, The network path cannot be accessed by an anonymous user. So

SPSecurity.RunWithElevatedPrivileges

has done the trick for me.
Thank you all for your valuable help at right time.

梦境 2024-12-27 17:26:11

您可以使用 LogOnUser 函数以本地用户身份登录:

        [DllImport("advapi32.dll", SetLastError = true)]
        private static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);

        // types 
        const int LOGON32_LOGON_INTERACTIVE = 2;
        const int LOGON32_LOGON_NETWORK = 3;
        const int LOGON32_LOGON_NEW_CREDENTIALS = 9;

        // providers 
        const int LOGON32_PROVIDER_DEFAULT = 0;
        const int LOGON32_PROVIDER_WINNT35 = 1;
        const int LOGON32_PROVIDER_WINNT40 = 2;
        const int LOGON32_PROVIDER_WINNT50 = 3;

用法:

IntPtr token = IntPtr.Zero;
LogonUser("User Name", "Domain Name", "Password", LOGON32_LOGON_NEW_CREDENTIALS, LOGON32_PROVIDER_DEFAULT, ref token);

using (WindowsImpersonationContext user = new WindowsIdentity(token).Impersonate())
{
    // Do file operations here...
}

You can Login as local user using LogOnUser function:

        [DllImport("advapi32.dll", SetLastError = true)]
        private static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);

        // types 
        const int LOGON32_LOGON_INTERACTIVE = 2;
        const int LOGON32_LOGON_NETWORK = 3;
        const int LOGON32_LOGON_NEW_CREDENTIALS = 9;

        // providers 
        const int LOGON32_PROVIDER_DEFAULT = 0;
        const int LOGON32_PROVIDER_WINNT35 = 1;
        const int LOGON32_PROVIDER_WINNT40 = 2;
        const int LOGON32_PROVIDER_WINNT50 = 3;

Usage:

IntPtr token = IntPtr.Zero;
LogonUser("User Name", "Domain Name", "Password", LOGON32_LOGON_NEW_CREDENTIALS, LOGON32_PROVIDER_DEFAULT, ref token);

using (WindowsImpersonationContext user = new WindowsIdentity(token).Impersonate())
{
    // Do file operations here...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文